@guiexpert/react-table 0.0.1 → 1.0.2

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/.eslintrc.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "extends": [
3
+ "plugin:@nrwl/nx/react",
4
+ "../../.eslintrc.json"
5
+ ],
6
+ "ignorePatterns": [
7
+ "!**/*"
8
+ ],
9
+ "overrides": [
10
+ {
11
+ "files": [
12
+ "*.ts",
13
+ "*.tsx",
14
+ "*.js",
15
+ "*.jsx"
16
+ ],
17
+ "rules": {}
18
+ },
19
+ {
20
+ "files": [
21
+ "*.ts",
22
+ "*.tsx"
23
+ ],
24
+ "rules": {}
25
+ },
26
+ {
27
+ "files": [
28
+ "*.js",
29
+ "*.jsx"
30
+ ],
31
+ "rules": {}
32
+ }
33
+ ]
34
+ }
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/react-table.iml" filepath="$PROJECT_DIR$/.idea/react-table.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+
2
+ # ReactTable (GuiExpert Table)
3
+
4
+ This is the react component of the GuiExpert Table Project.
5
+
6
+ ## Become a master at creating web applications with large tables
7
+
8
+ This is the UI-agnostic table component for your next web app. 😊
9
+
10
+ <img src="https://raw.githubusercontent.com/guiexperttable/table-website/main/src/assets/screens/heatmap.png" width="50%">
11
+
12
+ ### Features
13
+ - Handle large datasets easily
14
+ - Excellent performance for large tables by vertical and horizontal virtual scrolling
15
+ - Fully-featured (advanced sorting and filtering)
16
+ - Highly customizable data grid
17
+ - Outstanding performance
18
+ - No third-party dependencies
19
+ - UI-agnostic
20
+ - Column Interactions (resize, reorder)
21
+ - Sorting Rows
22
+ - Row, Column, and Range Selection
23
+ - Single and Multi Selection
24
+ - UI-agnostic
25
+ - Row and Column Spanning
26
+ - Fixed Columns (Left and Right)
27
+ - Tree table (Hierarchical View)
28
+ - Accessibility support: Keyboard Shortcuts
29
+ - Custom Filtering
30
+ - In-place Cell Editing
31
+ - Userdefined Key and Mouse Events
32
+ - Customizable Look & Feel (via CSS variables)
33
+ - Row sorting
34
+ - Column Reordering (Drag and Drop)
35
+ - State Persistence (Row Sorting, Column Order, Selection)
36
+ - Customizable Cell Contents via Renderer for Header, Body and Footer
37
+ - Full control over the HTML structure and style
38
+
39
+
40
+ ## Links
41
+
42
+ - [Demos](https://gui.expert/demos)
43
+ - [Documentation](https://gui.expert/doc)
44
+ - [API](https://gui.expert/api)
45
+
46
+ ## Get Started
47
+
48
+ Add the following two NPM packages to your existing react project (run this in your project root directory):
49
+
50
+ ```
51
+ npm install --save @guiexpert/table @guiexpert/react-table
52
+ ```
53
+
54
+ Add ReactTable component to a template:
55
+
56
+ ```
57
+ return (
58
+ <>
59
+ <ReactTable
60
+ tableModel={tableModel}
61
+ tableOptions={new TableOptions}
62
+ />
63
+ </>
64
+ );
65
+ ```
66
+
67
+ Import the following classes in your component:
68
+ ```
69
+ import { ReactTable } from "@guiexpert/react-table";
70
+ import {
71
+ GeMouseEvent,
72
+ TableApi
73
+ TableModelFactory,
74
+ TableModelIf,
75
+ TableOptions,
76
+ TableOptionsIf
77
+ } from "@guiexpert/table";
78
+ ```
79
+
80
+
81
+ Add a tableModel property and a onTableReady method to the component:
82
+
83
+ ```
84
+ const tableModel: TableModelIf = TableModelFactory
85
+ .createByArrayOfArraysParams<any>(param: {
86
+ columnLabels: [
87
+ ['Header 1', 'Header 2']
88
+ ],
89
+ data: [
90
+ ['Text 1a', 'Text 2a'],
91
+ ['Text 1b', 'Text 2b'],
92
+ ]
93
+ };
94
+
95
+ function onTableReady(api: TableApi) {
96
+ console.info("onTableReady API:", api);
97
+ }
98
+ ```
99
+
100
+ There are numerous possibilities to create table models.
101
+ Please refer to the [Documentation](https://gui.expert/doc) for further information or the [Demo](https://gui.expert/demos) section for examples.
102
+
103
+
package/jest.config.ts ADDED
@@ -0,0 +1,11 @@
1
+ /* eslint-disable */
2
+ export default {
3
+ displayName: "react-table",
4
+ preset: "../../jest.preset.js",
5
+ transform: {
6
+ "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nrwl/react/plugins/jest",
7
+ "^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nrwl/react/babel"] }]
8
+ },
9
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
10
+ coverageDirectory: "../../coverage/libs/react-table"
11
+ };
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@guiexpert/react-table",
3
- "version": "0.0.1",
3
+ "version": "1.0.2",
4
+ "scripts": {
5
+ "publish": "npm publish"
6
+ },
4
7
  "main": "./index.js",
5
8
  "types": "./index.d.ts",
6
9
  "exports": {
package/project.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@guiexpert/react-table",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "libs/react-table/src",
5
+ "projectType": "library",
6
+ "tags": [],
7
+ "targets": {
8
+ "lint": {
9
+ "executor": "@nrwl/linter:eslint",
10
+ "outputs": [
11
+ "{options.outputFile}"
12
+ ],
13
+ "options": {
14
+ "lintFilePatterns": [
15
+ "libs/react-table/**/*.{ts,tsx,js,jsx}"
16
+ ]
17
+ }
18
+ },
19
+ "build": {
20
+ "executor": "@nrwl/vite:build",
21
+ "outputs": [
22
+ "{options.outputPath}"
23
+ ],
24
+ "defaultConfiguration": "production",
25
+ "options": {
26
+ "outputPath": "dist/libs/react-table"
27
+ },
28
+ "configurations": {
29
+ "development": {
30
+ "mode": "development"
31
+ },
32
+ "production": {
33
+ "mode": "production"
34
+ }
35
+ }
36
+ },
37
+ "test": {
38
+ "executor": "@nrwl/jest:jest",
39
+ "outputs": [
40
+ "{workspaceRoot}/coverage/{projectRoot}"
41
+ ],
42
+ "options": {
43
+ "jestConfig": "libs/react-table/jest.config.ts",
44
+ "passWithNoTests": true
45
+ },
46
+ "configurations": {
47
+ "ci": {
48
+ "ci": true,
49
+ "codeCoverage": true
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
@@ -1,2 +1,2 @@
1
- export * from "./lib/react-table";
1
+ export * from "./lib/guiexpert-table";
2
2
  export * from "./lib/component-renderer-wrapper";
@@ -0,0 +1,39 @@
1
+ import { AreaIdent, AreaModelIf, CellRendererIf, DomServiceIf, RendererCleanupFnType } from "@guiexpert/table";
2
+ import { createRoot } from "react-dom/client";
3
+
4
+
5
+ export class ComponentRendererWrapper implements CellRendererIf {
6
+
7
+ constructor(
8
+ private readonly Component: any
9
+ ) {
10
+ console.info(Component);
11
+ }
12
+
13
+ render(
14
+ cellDiv: HTMLDivElement,
15
+ rowIndex: number,
16
+ columnIndex: number,
17
+ areaIdent: AreaIdent,
18
+ areaModel: AreaModelIf,
19
+ cellValue: any,
20
+ domService: DomServiceIf): RendererCleanupFnType | undefined {
21
+
22
+ const props = {
23
+ cellDiv,
24
+ rowIndex,
25
+ columnIndex,
26
+ areaIdent,
27
+ areaModel,
28
+ cellValue
29
+ };
30
+ const root = createRoot(cellDiv, {});
31
+ root.render(this.Component(props));
32
+
33
+ return () => {
34
+ root.unmount();
35
+ };
36
+ }
37
+
38
+
39
+ }
@@ -0,0 +1,126 @@
1
+ import {
2
+ GeModelChangeEvent,
3
+ GeMouseEvent,
4
+ SimpleDomService,
5
+ TableApi,
6
+ TableModelIf,
7
+ TableOptions,
8
+ TableScope
9
+ } from "@guiexpert/table";
10
+ import React, { useEffect, useRef } from "react";
11
+
12
+ export type GeMouseEventFn = (evt: GeMouseEvent) => {};
13
+ export type GeCheckboxEventFn = (evt: any[]) => {};
14
+ export type GeTableReadyEventFn = (evt: TableApi) => {};
15
+ export type GeModelChangeEventFn = (evt: GeModelChangeEvent) => {};
16
+
17
+ export interface GuiexpertTableProps {
18
+ tableModel: TableModelIf,
19
+ tableOptions?: TableOptions,
20
+ mouseMoved?: GeMouseEventFn,
21
+ contextmenu?: GeMouseEventFn,
22
+ mouseClicked?: GeMouseEventFn,
23
+ mouseDragging?: GeMouseEventFn,
24
+ mouseDraggingEnd?: GeMouseEventFn,
25
+ checkboxChanged?: GeCheckboxEventFn,
26
+ modelChanged?: GeModelChangeEventFn,
27
+ tableReady?: GeTableReadyEventFn
28
+ }
29
+
30
+ export function GuiexpertTable(
31
+ {
32
+ tableModel,
33
+ tableOptions = new TableOptions(),
34
+ mouseMoved,
35
+ checkboxChanged,
36
+ contextmenu,
37
+ modelChanged,
38
+ mouseClicked,
39
+ mouseDragging,
40
+ mouseDraggingEnd,
41
+ tableReady
42
+ }: GuiexpertTableProps) {
43
+
44
+ const myContainer = useRef(null);
45
+ let initialized = false;
46
+
47
+ useEffect(() => {
48
+ if (myContainer.current && !initialized) {
49
+ initTable(myContainer.current);
50
+ initialized = true;
51
+ }
52
+ });
53
+
54
+ let root: HTMLDivElement | null;
55
+
56
+ const initTable = (ele: HTMLDivElement) => {
57
+ const listener = {
58
+ onCheckboxChanged: (evt: any[]) => {
59
+ if (checkboxChanged) {
60
+ checkboxChanged(evt);
61
+ }
62
+ },
63
+
64
+ onContextmenu: (evt: GeMouseEvent) => {
65
+ if (contextmenu) {
66
+ contextmenu(evt);
67
+ }
68
+ },
69
+
70
+ onModelChanged: (evt: GeModelChangeEvent) => {
71
+ if (modelChanged) {
72
+ modelChanged(evt);
73
+ }
74
+ },
75
+
76
+ onMouseClicked: (evt: GeMouseEvent) => {
77
+ if (mouseClicked) {
78
+ mouseClicked(evt);
79
+ }
80
+ },
81
+
82
+ onMouseDragging: (evt: GeMouseEvent) => {
83
+ if (mouseDragging) {
84
+ mouseDragging(evt);
85
+ }
86
+ },
87
+
88
+ onMouseDraggingEnd: (evt: GeMouseEvent) => {
89
+ if (mouseDraggingEnd) {
90
+ mouseDraggingEnd(evt);
91
+ }
92
+ },
93
+
94
+ onMouseMoved: (evt: GeMouseEvent) => {
95
+ if (mouseMoved) {
96
+ mouseMoved(evt);
97
+ }
98
+ }
99
+ };
100
+
101
+ const tableScope = new TableScope(
102
+ ele, tableModel, new SimpleDomService(), tableOptions, listener
103
+ );
104
+ tableScope.firstInit();
105
+ if (tableReady) {
106
+ tableReady(tableScope.getApi());
107
+ }
108
+ };
109
+
110
+ return (
111
+ <div
112
+ ref={myContainer}
113
+ className="container-div"
114
+ style={{
115
+ width: "100%",
116
+ height: "100%",
117
+ backgroundColor: "transparent",
118
+ padding: "0",
119
+ margin: "0"
120
+ }}></div>
121
+ );
122
+ }
123
+
124
+ export default GuiexpertTable;
125
+
126
+
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Replace this with your own classes
3
+ *
4
+ * e.g.
5
+ * .container {
6
+ * }
7
+ */
8
+
@@ -0,0 +1,6 @@
1
+ describe("ReactTable", () => {
2
+ // it("should render successfully", () => {
3
+ // const { baseElement } = render(<ReactTable />);
4
+ // expect(baseElement).toBeTruthy();
5
+ // });
6
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react-jsx",
4
+ "allowJs": false,
5
+ "esModuleInterop": false,
6
+ "allowSyntheticDefaultImports": true,
7
+ "strict": true,
8
+ "types": [
9
+ "vite/client"
10
+ ]
11
+ },
12
+ "files": [],
13
+ "include": [],
14
+ "references": [
15
+ {
16
+ "path": "./tsconfig.lib.json"
17
+ },
18
+ {
19
+ "path": "./tsconfig.spec.json"
20
+ }
21
+ ],
22
+ "extends": "../../tsconfig.base.json"
23
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "types": [
6
+ "node",
7
+ "vite/client"
8
+ ]
9
+ },
10
+ "files": [
11
+ "../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
12
+ "../../node_modules/@nrwl/react/typings/image.d.ts"
13
+ ],
14
+ "exclude": [
15
+ "**/*.spec.ts",
16
+ "**/*.test.ts",
17
+ "**/*.spec.tsx",
18
+ "**/*.test.tsx",
19
+ "**/*.spec.js",
20
+ "**/*.test.js",
21
+ "**/*.spec.jsx",
22
+ "**/*.test.jsx"
23
+ ],
24
+ "include": [
25
+ "**/*.js",
26
+ "**/*.jsx",
27
+ "**/*.ts",
28
+ "**/*.tsx"
29
+ ]
30
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": [
7
+ "jest",
8
+ "node"
9
+ ]
10
+ },
11
+ "include": [
12
+ "jest.config.ts",
13
+ "src/**/*.test.ts",
14
+ "src/**/*.spec.ts",
15
+ "src/**/*.test.tsx",
16
+ "src/**/*.spec.tsx",
17
+ "src/**/*.test.js",
18
+ "src/**/*.spec.js",
19
+ "src/**/*.test.jsx",
20
+ "src/**/*.spec.jsx",
21
+ "src/**/*.d.ts"
22
+ ]
23
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,49 @@
1
+ /// <reference types="vitest" />
2
+ import { defineConfig } from "vite";
3
+ import react from "@vitejs/plugin-react";
4
+ import viteTsConfigPaths from "vite-tsconfig-paths";
5
+ import dts from "vite-plugin-dts";
6
+ import { join } from "path";
7
+
8
+ export default defineConfig({
9
+ cacheDir: "../../node_modules/.vite/react-table",
10
+
11
+ plugins: [
12
+ dts({
13
+ entryRoot: "src",
14
+ tsConfigFilePath: join(__dirname, "tsconfig.lib.json"),
15
+ skipDiagnostics: true
16
+ }),
17
+ react(),
18
+ viteTsConfigPaths({
19
+ root: "../../"
20
+ })
21
+ ],
22
+
23
+ // Uncomment this if you are using workers.
24
+ // worker: {
25
+ // plugins: [
26
+ // viteTsConfigPaths({
27
+ // root: '../../',
28
+ // }),
29
+ // ],
30
+ // },
31
+
32
+ // Configuration for building your library.
33
+ // See: https://vitejs.dev/guide/build.html#library-mode
34
+ build: {
35
+ lib: {
36
+ // Could also be a dictionary or array of multiple entry points.
37
+ entry: "src/index.ts",
38
+ name: "react-table",
39
+ fileName: "index",
40
+ // Change this to the formats you want to support.
41
+ // Don't forgot to update your package.json as well.
42
+ formats: ["es", "cjs"]
43
+ },
44
+ rollupOptions: {
45
+ // External packages that should not be bundled into your library.
46
+ external: ["react", "react-dom", "react/jsx-runtime"]
47
+ }
48
+ }
49
+ });