@guiexpert/vue3-table 0.0.1 → 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 ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/env"
5
+ ]
6
+ ]
7
+ }
package/.eslintrc.js ADDED
@@ -0,0 +1,79 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: {
4
+ node: true
5
+ },
6
+ extends: [
7
+ "plugin:vue/vue3-recommended",
8
+ "plugin:@intlify/vue-i18n/recommended",
9
+ "@vue/typescript/recommended",
10
+ "prettier"
11
+ ],
12
+ plugins: ["import"],
13
+ parser: "vue-eslint-parser",
14
+ parserOptions: { ecmaVersion: 2020 },
15
+ ignorePatterns: ["node_modules/"],
16
+ rules: {
17
+ "no-console": "off",
18
+ "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
19
+ "space-before-function-paren": [
20
+ "error",
21
+ { anonymous: "never", named: "never", asyncArrow: "always" }
22
+ ],
23
+ "padded-blocks": "off",
24
+ "no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
25
+ "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
26
+ "no-multiple-empty-lines": ["error", { max: 1 }],
27
+ "keyword-spacing": ["error", { after: true }],
28
+ "max-len": ["error", { code: 100, ignorePattern: "^\\s*<path" }],
29
+ "no-param-reassign": [2, { props: false }],
30
+ "object-curly-newline": [
31
+ "error",
32
+ {
33
+ consistent: true,
34
+ multiline: true
35
+ }
36
+ ],
37
+ "no-extra-boolean-cast": "error",
38
+ "import/extensions": [
39
+ "error",
40
+ {
41
+ ts: "never",
42
+ js: "never",
43
+ vue: "always",
44
+ json: "always",
45
+ png: "always",
46
+ jpg: "always",
47
+ mp3: "always",
48
+ mp4: "always"
49
+ }
50
+ ],
51
+ indent: ["error", 2, { SwitchCase: 0 }],
52
+ "vue/attribute-hyphenation": ["error", "never"],
53
+ // TODO -- figure out how to get this to work with prettier
54
+ // 'vue/html-indent': ['error', 2, { baseIndent: 0 }],
55
+ "vue/singleline-html-element-content-newline": [
56
+ "error",
57
+ {
58
+ ignoreWhenNoAttributes: true,
59
+ ignoreWhenEmpty: true
60
+ }
61
+ ],
62
+ "vue/max-attributes-per-line": [
63
+ "error",
64
+ {
65
+ singleline: 3
66
+ }
67
+ ],
68
+ "vue/no-v-html": "off",
69
+ "@intlify/vue-i18n/no-v-html": "off",
70
+ "@intlify/vue-i18n/no-unused-keys": [
71
+ "error",
72
+ {
73
+ src: "./src",
74
+ extensions: [".js", ".vue"]
75
+ }
76
+ ],
77
+ "@intlify/vue-i18n/no-raw-text": "error"
78
+ }
79
+ };
@@ -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/vue3-table.iml" filepath="$PROJECT_DIR$/.idea/vue3-table.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
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>
@@ -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/README.md ADDED
@@ -0,0 +1,102 @@
1
+
2
+ # guiexpert-table (Vue)
3
+
4
+ This is the vue 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/vue3-table
52
+ ```
53
+
54
+ Add guiexpert-table component to a template:
55
+
56
+ ```
57
+ <guiexpert-table
58
+ :tableModel="tableModel"
59
+ @tableReady="onTableReady($event)"
60
+ ></guiexpert-table>
61
+ ```
62
+
63
+ Import the following classes in your component:
64
+ ```
65
+ <script lang="ts" setup>
66
+
67
+ import { GuiexpertTable } from "@guiexpert/vue3-table";
68
+ import {
69
+ GeMouseEvent,
70
+ TableApi
71
+ TableModelFactory,
72
+ TableModelIf,
73
+ TableOptions,
74
+ TableOptionsIf
75
+ } from "@guiexpert/table";
76
+ ```
77
+
78
+
79
+ Add a tableModel property and a onTableReady method to the component:
80
+
81
+ ```
82
+ const tableModel: TableModelIf = TableModelFactory
83
+ .createByArrayOfArraysParams<any>(param: {
84
+ columnLabels: [
85
+ ['Header 1', 'Header 2']
86
+ ],
87
+ data: [
88
+ ['Text 1a', 'Text 2a'],
89
+ ['Text 1b', 'Text 2b'],
90
+ ]
91
+ };
92
+
93
+ function onTableReady(api: TableApi) {
94
+ console.info("onTableReady API:", api);
95
+ }
96
+ ```
97
+
98
+ There are numerous possibilities to create table models.
99
+ Please refer to the [Documentation](https://gui.expert/doc) for further information or the [Demo](https://gui.expert/demos) section for examples.
100
+
101
+
102
+
@@ -0,0 +1,16 @@
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+ // @ts-nocheck
4
+ // Generated by unplugin-vue-components
5
+ // Read more: https://github.com/vuejs/core/pull/3399
6
+ import '@vue/runtime-core'
7
+
8
+ export {}
9
+
10
+ declare module '@vue/runtime-core' {
11
+ export interface GlobalComponents {
12
+ GuiexpertTable: typeof import('./src/lib/GuiexpertTable.vue')['default']
13
+ RouterLink: typeof import('vue-router')['RouterLink']
14
+ RouterView: typeof import('vue-router')['RouterView']
15
+ }
16
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "name": "Use fixtures to represent data"
3
+ }
@@ -0,0 +1,10 @@
1
+ import { devServer } from "@cypress/vite-dev-server";
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ module.exports = (on: any, config: any) => {
5
+ on("dev-server:start", (options: Cypress.DevServerConfig) =>
6
+ devServer(options)
7
+ );
8
+
9
+ return config;
10
+ };
@@ -0,0 +1 @@
1
+ import "@cypress/code-coverage/support";
package/jest.config.ts ADDED
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ displayName: "vue3-table",
3
+ globals: {
4
+ "vue-jest": {
5
+ tsConfig: "./libs/vue3-table/tsconfig.spec.json"
6
+ }
7
+ },
8
+ transform: {
9
+ "^.+\\.vue$": "@vue/vue3-jest",
10
+ "^.+\\.jsx$": "babel-jest",
11
+ "^.+\\.tsx?$": "ts-jest"
12
+ },
13
+ testEnvironmentOptions: {
14
+ customExportConditions: ["node", "node-addons"]
15
+ },
16
+ testEnvironment: "jsdom",
17
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx", "vue"],
18
+ testTimeout: 10000
19
+ };
package/package.json CHANGED
@@ -1,5 +1,15 @@
1
1
  {
2
2
  "name": "@guiexpert/vue3-table",
3
- "version": "0.0.1",
4
- "type": "commonjs"
3
+ "version": "1.0.1",
4
+ "scripts": {
5
+ "publish": "npm publish"
6
+ },
7
+ "main": "./index.js",
8
+ "types": "./index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./index.mjs",
12
+ "require": "./index.js"
13
+ }
14
+ }
5
15
  }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ plugins: []
3
+ };
package/project.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@guiexpert/vue3-table",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "projectType": "library",
5
+ "sourceRoot": "libs/vue3-table/src",
6
+ "targets": {
7
+ "build": {
8
+ "executor": "nx-vue3-vite:build-app",
9
+ "options": {
10
+ "dist": "dist/libs/vue3-table"
11
+ }
12
+ },
13
+ "e2e": {
14
+ "executor": "nx-vue3-vite:cypress",
15
+ "options": {
16
+ "cypressConfig": "libs/vue3-table/cypress.json",
17
+ "testingType": "component"
18
+ }
19
+ },
20
+ "lint": {
21
+ "executor": "@nrwl/linter:eslint",
22
+ "options": {
23
+ "lintFilePatterns": [
24
+ "libs/vue3-table/**/*.{js,jsx,ts,tsx,vue}"
25
+ ]
26
+ }
27
+ },
28
+ "test": {
29
+ "executor": "@nrwl/vite:test",
30
+ "outputs": [
31
+ "coverage/libs/e2e/apps"
32
+ ],
33
+ "options": {
34
+ "config": "vite.config.ts",
35
+ "passWithNoTests": true
36
+ }
37
+ }
38
+ },
39
+ "tags": []
40
+ }
File without changes
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default as GuiexpertTable } from "./lib/GuiexpertTable.vue";
2
+ export { ComponentRendererWrapper } from "./lib/ComponentRendererWrapper";
@@ -0,0 +1,61 @@
1
+ import { AreaIdent, AreaModelIf, CellRendererIf, DomServiceIf, RendererCleanupFnType } from "@guiexpert/table";
2
+ import { createVNode, render } from "vue";
3
+ import { AppContext, VNode, VNodeProps } from "@vue/runtime-core";
4
+
5
+ declare type Data = Record<string, unknown>;
6
+
7
+ export class ComponentRendererWrapper implements CellRendererIf {
8
+
9
+ constructor(
10
+ private readonly component: any,
11
+ private readonly appContext: AppContext | null
12
+ ) {
13
+ }
14
+
15
+ render(
16
+ cellDiv: HTMLDivElement,
17
+ rowIndex: number,
18
+ columnIndex: number,
19
+ areaIdent: AreaIdent,
20
+ areaModel: AreaModelIf,
21
+ cellValue: any,
22
+ _domService: DomServiceIf): RendererCleanupFnType | undefined {
23
+
24
+ const cleanupFn = this.mount(
25
+ this.component,
26
+ {
27
+ cellDiv,
28
+ rowIndex,
29
+ columnIndex,
30
+ areaIdent,
31
+ areaModel,
32
+ cellValue
33
+ },
34
+ this.appContext,
35
+ cellDiv
36
+ );
37
+ return cleanupFn;
38
+ }
39
+
40
+
41
+ private mount(
42
+ component: any,
43
+ props: (Data & VNodeProps) | null,
44
+ appContext: AppContext | null,
45
+ cellDiv: HTMLDivElement
46
+ ) {
47
+ let vNode: VNode = createVNode(component, props);
48
+
49
+ vNode.appContext = appContext;
50
+ render(vNode, cellDiv);
51
+
52
+ const cleanupFn = () => {
53
+ if (cellDiv) {
54
+ render(null, cellDiv);
55
+ }
56
+ };
57
+
58
+ return cleanupFn;
59
+ }
60
+
61
+ }
@@ -0,0 +1,9 @@
1
+ import { mount } from "@vue/test-utils";
2
+ import { expect, test } from "vitest";
3
+ import GuiexpertTable from "./GuiexpertTable.vue";
4
+
5
+ test("shows text", () => {
6
+ expect(GuiexpertTable).toBeTruthy();
7
+ const wrapper = mount(GuiexpertTable);
8
+ expect(wrapper.text()).toContain("GuiexpertTable");
9
+ });
@@ -0,0 +1,97 @@
1
+ <template>
2
+ <div
3
+ ref="root"
4
+ class="container-div"
5
+ style="width: 100%; height: 100%; background-color: transparent; padding: 0; margin: 0">
6
+ </div>
7
+ </template>
8
+
9
+ <script lang="ts">
10
+ import { GeModelChangeEvent, GeMouseEvent, SimpleDomService, TableOptions, TableScope } from "@guiexpert/table";
11
+ import { defineComponent, onMounted, ref } from "vue";
12
+
13
+
14
+ export default defineComponent({
15
+ inheritAttrs: false,
16
+ props: {
17
+ tableModel: {
18
+ required: true
19
+ },
20
+ tableOptions: {
21
+ required: false,
22
+ default: new TableOptions()
23
+ },
24
+ debounceMouseClickDelay: {
25
+ required: false,
26
+ default: 150
27
+ }
28
+ },
29
+ emits: [
30
+ "tableReady",
31
+ "mouseClicked",
32
+ "mouseDragging",
33
+ "checkboxChanged",
34
+ "contextmenu",
35
+ "modelChanged",
36
+ "mouseDraggingEnd",
37
+ "mouseMoved"
38
+ ],
39
+
40
+ setup(props, { emit }) {
41
+ const root = ref(null);
42
+
43
+ const initTable = (ele: HTMLDivElement) => {
44
+
45
+ const listener = {
46
+
47
+ onCheckboxChanged: (evt: any[]) => {
48
+ emit("checkboxChanged", evt);
49
+ },
50
+
51
+ onContextmenu: (evt: GeMouseEvent) => {
52
+ emit("contextmenu", evt);
53
+ },
54
+
55
+ onModelChanged: (evt: GeModelChangeEvent) => {
56
+ emit("modelChanged", evt);
57
+ },
58
+
59
+ onMouseClicked: (evt: GeMouseEvent) => {
60
+ emit("mouseClicked", evt);
61
+ },
62
+
63
+ onMouseDragging: (evt: GeMouseEvent) => {
64
+ emit("mouseDragging", evt);
65
+ },
66
+
67
+ onMouseDraggingEnd: (evt: GeMouseEvent) => {
68
+ emit("mouseDraggingEnd", evt);
69
+ },
70
+
71
+ onMouseMoved: (evt: GeMouseEvent) => {
72
+ emit("mouseMoved", evt);
73
+ }
74
+ };
75
+
76
+ const tableScope = new TableScope(
77
+ ele, props.tableModel, new SimpleDomService(), props.tableOptions, listener
78
+ );
79
+ tableScope.firstInit();
80
+ emit("tableReady", tableScope.getApi());
81
+ };
82
+
83
+
84
+ onMounted(() => {
85
+ if (root.value) {
86
+ initTable(root.value as HTMLDivElement);
87
+ }
88
+ });
89
+
90
+ return {
91
+ root
92
+ };
93
+ }
94
+ });
95
+
96
+ </script>
97
+
@@ -0,0 +1,15 @@
1
+ declare module "*.vue" {
2
+ import type { DefineComponent } from "vue";
3
+ import { TableModelIf } from "../../table/src";
4
+
5
+ import { TableModelIf, TableOptions } from "@guiexpert/table";
6
+
7
+ // eslint-disable-next-line
8
+ const component: DefineComponent<{
9
+ props: {
10
+ tableModel: TableModelIf,
11
+ tableOptions: TableOptions
12
+ },
13
+ }, {}, any>;
14
+ export default component;
15
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ // Enables stricter inference for data properties on `this`
5
+ "strict": true,
6
+ "allowJs": true,
7
+ "jsx": "preserve",
8
+ "esModuleInterop": true,
9
+ "allowSyntheticDefaultImports": true,
10
+ "target": "ESNext",
11
+ "paths": {
12
+ "@assets/*": [
13
+ "./src/assets/*"
14
+ ],
15
+ "@lib/*": [
16
+ "./src/lib/*"
17
+ ]
18
+ }
19
+ },
20
+ "references": [
21
+ {
22
+ "path": "./tsconfig.lib.json"
23
+ },
24
+ {
25
+ "path": "./tsconfig.spec.json"
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "types": [
6
+ "vue-i18n",
7
+ "node"
8
+ ],
9
+ "composite": true
10
+ },
11
+ "exclude": [
12
+ "**/*.spec.js",
13
+ "**/*.spec.jsx",
14
+ "**/*.spec.ts",
15
+ "**/*.spec.tsx"
16
+ ],
17
+ "include": [
18
+ "**/*.js",
19
+ "**/*.jsx",
20
+ "**/*.ts",
21
+ "**/*.tsx",
22
+ "**/*.vue",
23
+ "**/*.json"
24
+ ]
25
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": [
7
+ "vue-i18n",
8
+ "jest",
9
+ "node"
10
+ ],
11
+ "composite": true
12
+ },
13
+ "include": [
14
+ "**/*.spec.ts",
15
+ "**/*.spec.tsx",
16
+ "**/*.vue",
17
+ "**/*.d.ts",
18
+ "**/*.ts"
19
+ ]
20
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,41 @@
1
+ import path from "path";
2
+ import { defineConfig } from "vite";
3
+ import Vue from "@vitejs/plugin-vue";
4
+ import Components from "unplugin-vue-components/vite";
5
+ import { tsconfigBaseAliases } from "nx-vue3-vite";
6
+
7
+ module.exports = defineConfig({
8
+ assetsInclude: /\.(pdf|jpg|png|svg)$/,
9
+ resolve: {
10
+ alias: {
11
+ ...tsconfigBaseAliases(__dirname)
12
+ // Add your aliases here
13
+ }
14
+ },
15
+ plugins: [
16
+ Vue(),
17
+ Components({
18
+ dirs: ["src/lib"]
19
+ })
20
+ ],
21
+ build: {
22
+ lib: {
23
+ entry: path.resolve(__dirname, "./src/index.ts"),
24
+ name: "vue3-table",
25
+ fileName: (format) => `vue3-table.${format}.js`
26
+ },
27
+ rollupOptions: {
28
+ // externalize deps that shouldn't be bundled
29
+ external: ["vue"],
30
+ output: {
31
+ // globals to use in the UMD build for externalized deps
32
+ globals: {
33
+ vue: "Vue"
34
+ }
35
+ }
36
+ }
37
+ },
38
+ test: {
39
+ environment: "happy-dom"
40
+ }
41
+ });