@guiexpert/preact-table 10.0.2 → 10.0.3
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.js +23 -0
- package/{ComponentRendererWrapper.d.ts → dist/ComponentRendererWrapper.d.ts} +1 -1
- package/{GuiexpertTable.d.ts → dist/GuiexpertTable.d.ts} +1 -1
- package/dist/README.md +102 -0
- package/dist/index.cjs +254 -0
- package/dist/index.js +3393 -0
- package/dist/package.json +43 -0
- package/jest.config.ts +10 -0
- package/package.json +28 -3
- package/patch.js +16 -0
- package/src/ComponentRendererWrapper.ts +60 -0
- package/src/GuiexpertTable.tsx +138 -0
- package/src/index.ts +2 -0
- package/tsconfig.json +28 -0
- package/tsconfig.lib.json +16 -0
- package/tsconfig.spec.json +17 -0
- package/vite.config.ts +73 -0
- package/index.cjs +0 -461
- package/index.js +0 -24187
- /package/{index.d.ts → dist/index.d.ts} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@guiexpert/preact-table",
|
|
3
|
+
"version": "10.0.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"lib": {
|
|
8
|
+
"entryFile": "src/index.ts"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"i": "pnpm i",
|
|
12
|
+
"build": "vite build",
|
|
13
|
+
"npm-pub:preact-table": "npm publish --access public"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./index.js",
|
|
18
|
+
"require": "./index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"tslib": "^2.3.0",
|
|
23
|
+
"@guiexpert/table": "workspace:^",
|
|
24
|
+
"preact": "^10.19.4"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"react-scripts-ts": "^3.1.0",
|
|
28
|
+
"@preact/preset-vite": "^2.6.0",
|
|
29
|
+
"@types/react": "^18.2.37",
|
|
30
|
+
"@types/react-dom": "^18.2.15",
|
|
31
|
+
"@types/node": "^20.11.17",
|
|
32
|
+
"vite": "^5.1.1",
|
|
33
|
+
"vite-plugin-dts": "^3.7.2",
|
|
34
|
+
"vite-plugin-eslint": "^1.8.1",
|
|
35
|
+
"vite-plugin-static-copy": "^0.17.0",
|
|
36
|
+
"vite-tsconfig-paths": "^4.2.1",
|
|
37
|
+
"vite-plugin-babel": "^1.2.0",
|
|
38
|
+
"@vitejs/plugin-react": "^4.1.1",
|
|
39
|
+
"ts-node": "10.9.1",
|
|
40
|
+
"tsconfig": "^7.0.0",
|
|
41
|
+
"typescript": "5.2.2"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export default {
|
|
3
|
+
displayName: "preact-table",
|
|
4
|
+
preset: "../../jest.preset.js",
|
|
5
|
+
transform: {
|
|
6
|
+
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
7
|
+
},
|
|
8
|
+
moduleFileExtensions: ["ts", "js", "html"],
|
|
9
|
+
coverageDirectory: "../../coverage/libs/preact-table"
|
|
10
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guiexpert/preact-table",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -8,12 +8,37 @@
|
|
|
8
8
|
"entryFile": "src/index.ts"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"
|
|
11
|
+
"i": "pnpm i",
|
|
12
|
+
"patch-version": "node patch.js",
|
|
13
|
+
"build": "vite build",
|
|
14
|
+
"npm-pub": "npm publish --access public"
|
|
12
15
|
},
|
|
13
16
|
"exports": {
|
|
14
17
|
".": {
|
|
15
18
|
"import": "./index.js",
|
|
16
19
|
"require": "./index.cjs"
|
|
17
20
|
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"tslib": "^2.3.0",
|
|
24
|
+
"@guiexpert/table": "workspace:^",
|
|
25
|
+
"preact": "^10.19.4"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"react-scripts-ts": "^3.1.0",
|
|
29
|
+
"@preact/preset-vite": "^2.6.0",
|
|
30
|
+
"@types/react": "^18.2.37",
|
|
31
|
+
"@types/react-dom": "^18.2.15",
|
|
32
|
+
"@types/node": "^20.11.17",
|
|
33
|
+
"vite": "^5.1.1",
|
|
34
|
+
"vite-plugin-dts": "^3.7.2",
|
|
35
|
+
"vite-plugin-eslint": "^1.8.1",
|
|
36
|
+
"vite-plugin-static-copy": "^0.17.0",
|
|
37
|
+
"vite-tsconfig-paths": "^4.2.1",
|
|
38
|
+
"vite-plugin-babel": "^1.2.0",
|
|
39
|
+
"@vitejs/plugin-react": "^4.1.1",
|
|
40
|
+
"ts-node": "10.9.1",
|
|
41
|
+
"tsconfig": "^7.0.0",
|
|
42
|
+
"typescript": "5.2.2"
|
|
18
43
|
}
|
|
19
|
-
}
|
|
44
|
+
}
|
package/patch.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
const packageJsonPath = 'package.json';
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
const pack = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
7
|
+
const currentVersion = pack.version;
|
|
8
|
+
const [major, minor, patch] = currentVersion.split('.').map(Number);
|
|
9
|
+
const newPatchVersion = `${major}.${minor}.${patch + 1}`;
|
|
10
|
+
pack.version = newPatchVersion;
|
|
11
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(pack, null, 2));
|
|
12
|
+
console.log(`${pack.name} -> version patched to ${newPatchVersion}.`);
|
|
13
|
+
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error('Error:', error);
|
|
16
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AreaIdent, AreaModelIf, CellRendererIf, DomServiceIf, RendererCleanupFnType } from "@guiexpert/table";
|
|
2
|
+
import {createRoot} from "react-dom/client";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class ComponentRendererWrapper implements CellRendererIf {
|
|
7
|
+
|
|
8
|
+
constructor(
|
|
9
|
+
private readonly Component: any
|
|
10
|
+
) {
|
|
11
|
+
console.info(Component);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
render(
|
|
15
|
+
cellDiv: HTMLDivElement,
|
|
16
|
+
rowIndex: number,
|
|
17
|
+
columnIndex: number,
|
|
18
|
+
areaIdent: AreaIdent,
|
|
19
|
+
areaModel: AreaModelIf,
|
|
20
|
+
cellValue: any,
|
|
21
|
+
domService: DomServiceIf): RendererCleanupFnType | undefined {
|
|
22
|
+
|
|
23
|
+
const props = {
|
|
24
|
+
cellDiv,
|
|
25
|
+
rowIndex,
|
|
26
|
+
columnIndex,
|
|
27
|
+
areaIdent,
|
|
28
|
+
areaModel,
|
|
29
|
+
cellValue
|
|
30
|
+
};
|
|
31
|
+
const root = createRoot(cellDiv, {});
|
|
32
|
+
root.render(this.Component(props));
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
root.unmount();
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// private mount(
|
|
41
|
+
// component: any,
|
|
42
|
+
// props: (Data & VNodeProps) | null,
|
|
43
|
+
// appContext: AppContext | null,
|
|
44
|
+
// cellDiv: HTMLDivElement
|
|
45
|
+
// ) {
|
|
46
|
+
// let vNode: VNode = createVNode(component, props);
|
|
47
|
+
//
|
|
48
|
+
// vNode.appContext = appContext;
|
|
49
|
+
// render(vNode, cellDiv);
|
|
50
|
+
//
|
|
51
|
+
// const cleanupFn = () => {
|
|
52
|
+
// if (cellDiv) {
|
|
53
|
+
// render(null, cellDiv);
|
|
54
|
+
// }
|
|
55
|
+
// };
|
|
56
|
+
//
|
|
57
|
+
// return cleanupFn;
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Component, createRef } from "preact";
|
|
2
|
+
import {
|
|
3
|
+
EventListenerIf, FocusModelIf,
|
|
4
|
+
GeModelChangeEvent,
|
|
5
|
+
GeMouseEvent, LicenseManager, SelectionModelIf,
|
|
6
|
+
SimpleDomService, TableApi,
|
|
7
|
+
TableModelIf,
|
|
8
|
+
TableOptions,
|
|
9
|
+
TableScope
|
|
10
|
+
} from '@guiexpert/table';
|
|
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
|
+
export type GeSelectionChangeEventFn = (evt: SelectionModelIf) => {};
|
|
17
|
+
export type GeFocusChangeEventFn = (evt: FocusModelIf) => {};
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export interface GuiexpertTableProps {
|
|
21
|
+
tableModel: TableModelIf,
|
|
22
|
+
tableOptions?: TableOptions,
|
|
23
|
+
mouseMoved?: GeMouseEventFn,
|
|
24
|
+
contextmenu?: GeMouseEventFn,
|
|
25
|
+
mouseClicked?: GeMouseEventFn,
|
|
26
|
+
mouseDragging?: GeMouseEventFn,
|
|
27
|
+
mouseDraggingEnd?: GeMouseEventFn,
|
|
28
|
+
checkboxChanged?: GeCheckboxEventFn,
|
|
29
|
+
modelChanged?: GeModelChangeEventFn,
|
|
30
|
+
tableReady?: GeTableReadyEventFn,
|
|
31
|
+
licenseKey?: string,
|
|
32
|
+
selectionChanged?: GeSelectionChangeEventFn;
|
|
33
|
+
focusChanged?: GeFocusChangeEventFn;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* GuiexpertTable is a React component that wraps the ExpertTable library.
|
|
39
|
+
* It displays a table with various event listeners and callback functions.
|
|
40
|
+
*/
|
|
41
|
+
export class GuiexpertTable extends Component<GuiexpertTableProps> {
|
|
42
|
+
|
|
43
|
+
ref = createRef();
|
|
44
|
+
|
|
45
|
+
constructor(props: GuiexpertTableProps) {
|
|
46
|
+
super(props);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
componentDidMount() {
|
|
50
|
+
const myContainer: HTMLDivElement = this.ref.current;
|
|
51
|
+
this.initTable(myContainer, this.props as GuiexpertTableProps);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
componentWillUnmount() {
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
initTable(ele: HTMLDivElement, props: GuiexpertTableProps) {
|
|
58
|
+
const listener: EventListenerIf = {
|
|
59
|
+
|
|
60
|
+
onSelectionChanged(model: SelectionModelIf): void {
|
|
61
|
+
if (props.selectionChanged) {
|
|
62
|
+
props.selectionChanged(model);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
onFocusChanged(model: FocusModelIf): void{
|
|
67
|
+
if (props.focusChanged) {
|
|
68
|
+
props.focusChanged(model);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
onCheckboxChanged: (evt: any[]) => {
|
|
74
|
+
if (props.checkboxChanged) {
|
|
75
|
+
props.checkboxChanged(evt);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
onContextmenu: (evt: GeMouseEvent) => {
|
|
80
|
+
if (props.contextmenu) {
|
|
81
|
+
props.contextmenu(evt);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
onModelChanged: (evt: GeModelChangeEvent) => {
|
|
86
|
+
if (props.modelChanged) {
|
|
87
|
+
props.modelChanged(evt);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
onMouseClicked: (evt: GeMouseEvent) => {
|
|
92
|
+
if (props.mouseClicked) {
|
|
93
|
+
props.mouseClicked(evt);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
onMouseDragging: (evt: GeMouseEvent) => {
|
|
98
|
+
if (props.mouseDragging) {
|
|
99
|
+
props.mouseDragging(evt);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
onMouseDraggingEnd: (evt: GeMouseEvent) => {
|
|
104
|
+
if (props.mouseDraggingEnd) {
|
|
105
|
+
props.mouseDraggingEnd(evt);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
onMouseMoved: (evt: GeMouseEvent) => {
|
|
110
|
+
// ignored
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const tableScope = new TableScope(
|
|
115
|
+
ele, props.tableModel, new SimpleDomService(), props.tableOptions ?? new TableOptions(), listener
|
|
116
|
+
);
|
|
117
|
+
tableScope.firstInit();
|
|
118
|
+
if (props.tableReady) {
|
|
119
|
+
props.tableReady(tableScope.getApi());
|
|
120
|
+
}
|
|
121
|
+
if (props.licenseKey) LicenseManager.getInstance().setLicenseKey(props.licenseKey);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
render() {
|
|
125
|
+
return <div
|
|
126
|
+
ref={this.ref}
|
|
127
|
+
className="container-div"
|
|
128
|
+
style={{
|
|
129
|
+
width: "100%",
|
|
130
|
+
height: "100%",
|
|
131
|
+
backgroundColor: "transparent",
|
|
132
|
+
padding: "0",
|
|
133
|
+
margin: "0"
|
|
134
|
+
}} />;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export default GuiexpertTable;
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"strict": true,
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"jsx": "preserve",
|
|
11
|
+
"jsxFactory": "h",
|
|
12
|
+
"jsxFragmentFactory": "Fragment",
|
|
13
|
+
"jsxImportSource": "preact",
|
|
14
|
+
"types": [
|
|
15
|
+
"vite/client"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"files": [],
|
|
19
|
+
"include": [],
|
|
20
|
+
"references": [
|
|
21
|
+
{
|
|
22
|
+
"path": "./tsconfig.lib.json"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"path": "./tsconfig.spec.json"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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/**/*.d.ts"
|
|
16
|
+
]
|
|
17
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
|
|
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
|
+
import {viteStaticCopy} from "vite-plugin-static-copy";
|
|
8
|
+
import { preact } from '@preact/preset-vite';
|
|
9
|
+
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
|
|
12
|
+
cacheDir: "../../node_modules/.vite/preact-table",
|
|
13
|
+
|
|
14
|
+
plugins: [
|
|
15
|
+
dts({
|
|
16
|
+
entryRoot: "src",
|
|
17
|
+
tsconfigPath: join(__dirname, "tsconfig.lib.json")
|
|
18
|
+
}),
|
|
19
|
+
// react(),
|
|
20
|
+
preact({include: ['**/*[jt]sx']}), // <-- add {include:...}
|
|
21
|
+
// viteTsConfigPaths({
|
|
22
|
+
// root: "./"
|
|
23
|
+
// }),
|
|
24
|
+
viteStaticCopy({
|
|
25
|
+
targets: [
|
|
26
|
+
{
|
|
27
|
+
src: 'README.md',
|
|
28
|
+
dest: './'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
src: 'package.json',
|
|
32
|
+
dest: './'
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
],
|
|
37
|
+
|
|
38
|
+
// Uncomment this if you are using workers.
|
|
39
|
+
// worker: {
|
|
40
|
+
// plugins: [
|
|
41
|
+
// viteTsConfigPaths({
|
|
42
|
+
// root: '../../',
|
|
43
|
+
// }),
|
|
44
|
+
// ],
|
|
45
|
+
// },
|
|
46
|
+
|
|
47
|
+
// Configuration for building your library.
|
|
48
|
+
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
49
|
+
build: {
|
|
50
|
+
lib: {
|
|
51
|
+
// Could also be a dictionary or array of multiple entry points.
|
|
52
|
+
entry: "src/index.ts",
|
|
53
|
+
name: "preact-table",
|
|
54
|
+
fileName: "index",
|
|
55
|
+
// Change this to the formats you want to support.
|
|
56
|
+
// Don't forgot to update your package.json as well.
|
|
57
|
+
formats: ["es", "cjs"]
|
|
58
|
+
},
|
|
59
|
+
rollupOptions: {
|
|
60
|
+
// External packages that should not be bundled into your library.
|
|
61
|
+
external: ["preact", "preact-dom", "preact/jsx-runtime"]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
resolve: {
|
|
65
|
+
alias: [
|
|
66
|
+
{
|
|
67
|
+
find: /@guiexpert\/table/,
|
|
68
|
+
replacement: join(__dirname, '..', 'table', 'src'),
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|