diff --git a/package-lock.json b/package-lock.json index 433654266c..9c605f6b2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "xpackages/deck-shim", "packages/dgrid", "packages/dgrid-shim", - "xpackages/dgrid2", + "packages/dgrid2", "xpackages/eclwatch", "packages/esbuild-plugins", "xpackages/form", @@ -585,7 +585,6 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -1285,6 +1284,10 @@ "resolved": "packages/dgrid-shim", "link": true }, + "node_modules/@hpcc-js/dgrid2": { + "resolved": "packages/dgrid2", + "link": true + }, "node_modules/@hpcc-js/esbuild-plugins": { "resolved": "packages/esbuild-plugins", "link": true @@ -7439,6 +7442,16 @@ "node": ">=0.10.0" } }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/cmd-shim": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.3.tgz", @@ -13300,6 +13313,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, "node_modules/loupe": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.2.tgz", @@ -17031,6 +17057,47 @@ "node": ">=0.10.0" } }, + "node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-data-grid": { + "version": "7.0.0-beta.47", + "resolved": "https://registry.npmjs.org/react-data-grid/-/react-data-grid-7.0.0-beta.47.tgz", + "integrity": "sha512-28kjsmwQGD/9RXYC50zn5Zv/SQMhBBoSvG5seq0fM8XXi9TZ0zr9Z5T3YJqLwcEtoNzTOq3y0njkmdujGkIwQQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "clsx": "^2.0.0" + }, + "peerDependencies": { + "react": "^18.0 || ^19.0", + "react-dom": "^18.0 || ^19.0" + } + }, + "node_modules/react-dom": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", + "dev": true, + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" + }, + "peerDependencies": { + "react": "^18.3.1" + } + }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -17829,6 +17896,16 @@ "node": ">=v12.22.7" } }, + "node_modules/scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + } + }, "node_modules/schema-utils": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz", @@ -21475,6 +21552,25 @@ "webpack-hasjs-plugin": "1.0.4" } }, + "packages/dgrid2": { + "name": "@hpcc-js/dgrid2", + "version": "3.0.0", + "license": "Apache-2.0", + "dependencies": { + "@hpcc-js/common": "^3.0.0", + "@hpcc-js/util": "^3.0.0" + }, + "devDependencies": { + "@hpcc-js/esbuild-plugins": "^1.2.0", + "react": "18.3.1", + "react-data-grid": "7.0.0-beta.47", + "react-dom": "18.3.1" + }, + "peerDependencies": { + "react": "^17.0.0 || ^18.0.0", + "react-dom": "^17.0.0 || ^18.0.0" + } + }, "packages/esbuild-plugins": { "name": "@hpcc-js/esbuild-plugins", "version": "1.2.0", diff --git a/package.json b/package.json index 319b1d5922..7a6a3cd2cc 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "xpackages/deck-shim", "packages/dgrid", "packages/dgrid-shim", - "xpackages/dgrid2", + "packages/dgrid2", "xpackages/eclwatch", "packages/esbuild-plugins", "xpackages/form", diff --git a/packages/chart/package.json b/packages/chart/package.json index 61a17384c1..3f3fdcb2ef 100644 --- a/packages/chart/package.json +++ b/packages/chart/package.json @@ -33,7 +33,7 @@ "test": "vitest run", "coverage": "vitest run --coverage", "update": "npx --yes npm-check-updates -u -t minor", - "update-major": "npx -yes npm-check-updates -u" + "update-major": "npx --yes npm-check-updates -u" }, "dependencies": { "@hpcc-js/api": "^3.1.0", diff --git a/packages/dgrid2/.vscode/launch.json b/packages/dgrid2/.vscode/launch.json index 5b64492e3f..7c2436335f 100644 --- a/packages/dgrid2/.vscode/launch.json +++ b/packages/dgrid2/.vscode/launch.json @@ -1,61 +1,47 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { - "name": "Dev", - "type": "chrome", + "name": "test-browser", + "type": "msedge", "request": "launch", - "url": "file:///${workspaceRoot}/index.html", - "runtimeArgs": [ - "--allow-file-access-from-files", - "--disable-web-security" + "url": "http://localhost:8888", + "webRoot": "${workspaceFolder}", + "outFiles": [ + "${workspaceFolder}/**/*.js", + "!**/node_modules/**" ], - "webRoot": "${workspaceRoot}" - }, - { - "name": "index.html (vite)", - "type": "pwa-msedge", - "request": "launch", - "url": "http://localhost:3000/index.html", - "webRoot": "${workspaceRoot}", - "preLaunchTask": "serve-vite", - "postDebugTask": "Terminate All Tasks" }, { - "name": "lws", - "type": "chrome", + "name": "test-node", + "type": "node", "request": "launch", - "url": "http://localhost:8080/../packages/graph/index.html", "runtimeArgs": [ - "--allow-file-access-from-files", - "--disable-web-security" + "run-script", + "test-node" ], - "webRoot": "${workspaceRoot}" - }, - { - "type": "chrome", - "request": "launch", - "name": "index.md", - "url": "${workspaceFolder}/../../website/index.html?debug=1#packages/graph/docs/index.md", - "runtimeArgs": [ - "--allow-file-access-from-files", - "--disable-web-security" + "runtimeExecutable": "npm", + "skipFiles": [ + "/**" + ], + "outFiles": [ + "${workspaceFolder}/**/*.js", + "!**/node_modules/**" ], - "webRoot": "${workspaceFolder}/../../website" }, { - "type": "chrome", + "name": "index.html", "request": "launch", - "name": "http index.md", - "url": "http://localhost:8080/${workspaceFolder}/../../website/index.html?debug=1#packages/graph/docs/index.md", + "type": "msedge", + "url": "file:///${workspaceFolder}/index.html", "runtimeArgs": [ - "--allow-file-access-from-files", "--disable-web-security" ], - "webRoot": "${workspaceFolder}/../../website" + "webRoot": "${workspaceFolder}", + "outFiles": [ + "${workspaceFolder}/**/*.js", + "!**/node_modules/**" + ] } ] } \ No newline at end of file diff --git a/packages/dgrid2/.vscode/tasks.json b/packages/dgrid2/.vscode/tasks.json index 38129bb20e..120545d06c 100644 --- a/packages/dgrid2/.vscode/tasks.json +++ b/packages/dgrid2/.vscode/tasks.json @@ -1,29 +1,20 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { + "label": "gen-types-watch", "type": "npm", - "label": "compile umd watch", - "script": "compile-umd-watch", - "problemMatcher": [], - "presentation": { - "group": "group-build" - } - }, - { - "type": "npm", - "label": "compile es6 watch", - "script": "compile-es6-watch", - "problemMatcher": [], + "script": "gen-types-watch", + "problemMatcher": [ + "$tsc-watch" + ], "presentation": { "group": "group-build" } }, { + "label": "bundle-watch", "type": "npm", - "label": "bundle watch", "script": "bundle-watch", "problemMatcher": [], "presentation": { @@ -31,46 +22,15 @@ } }, { - "label": "serve-vite", - "type": "npm", - "script": "serve-vite", - "problemMatcher": { - "owner": "node", - "fileLocation": [ - "relative", - "${workspaceFolder}" - ], - "pattern": { - "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", - "file": 1, - "line": 2, - "column": 3, - "severity": 4, - "message": 5 - }, - "background": { - "activeOnStart": true, - "beginsPattern": "^ vite", - "endsPattern": "^ ready in " - } - }, - "presentation": { - "group": "group-build" - }, - "isBackground": true - }, - { - "label": "build-local-dev-server", + "label": "build", "dependsOn": [ - "compile umd watch", - "compile es6 watch", - "bundle watch", + "gen-types-watch", + "bundle-watch", ], "group": { "kind": "build", "isDefault": true - }, - "problemMatcher": [] + } } ] } \ No newline at end of file diff --git a/packages/dgrid2/esbuild.js b/packages/dgrid2/esbuild.js new file mode 100644 index 0000000000..67b91a9988 --- /dev/null +++ b/packages/dgrid2/esbuild.js @@ -0,0 +1,29 @@ +import { browserTpl } from "@hpcc-js/esbuild-plugins"; +import pkg from "./package.json" with { type: "json" }; + +// config --- +await Promise.all([ + browserTpl("src/index.ts", "dist/index", { + keepNames: true, + alias: { + "d3-array": "@hpcc-js/common", + "d3-brush": "@hpcc-js/common", + "d3-collection": "@hpcc-js/common", + "d3-color": "@hpcc-js/common", + "d3-dispatch": "@hpcc-js/common", + "d3-drag": "@hpcc-js/common", + "d3-dsv": "@hpcc-js/common", + "d3-ease": "@hpcc-js/common", + "d3-format": "@hpcc-js/common", + "d3-interpolate": "@hpcc-js/common", + "d3-scale": "@hpcc-js/common", + "d3-selection": "@hpcc-js/common", + "d3-time-format": "@hpcc-js/common", + "d3-transition": "@hpcc-js/common", + "d3-zoom": "@hpcc-js/common" + }, + external: [ + ...Object.keys(pkg.dependencies), + ] + }) +]); diff --git a/packages/dgrid2/index.css b/packages/dgrid2/index.css deleted file mode 100644 index e216571c63..0000000000 --- a/packages/dgrid2/index.css +++ /dev/null @@ -1,16 +0,0 @@ -body { - padding: 0px; - margin: 8px; - background: lightgrey; - color: black; - overflow: hidden; -} - -#placeholder, -.placeholder { - position: absolute; - left: 18px; - top: 18px; - right: 18px; - bottom: 18px; -} \ No newline at end of file diff --git a/packages/dgrid2/index.html b/packages/dgrid2/index.html index e44c7aca08..3d9a327465 100644 --- a/packages/dgrid2/index.html +++ b/packages/dgrid2/index.html @@ -1,27 +1,91 @@ - + - - @hpcc-js/dgrid2 - - + Home + + + + -
-
+

ESM Quick Test

+
+ - \ No newline at end of file diff --git a/packages/dgrid2/package.json b/packages/dgrid2/package.json index 7005279ff8..9bac855cc6 100644 --- a/packages/dgrid2/package.json +++ b/packages/dgrid2/package.json @@ -1,52 +1,53 @@ { "name": "@hpcc-js/dgrid2", - "version": "2.5.0", + "version": "3.0.0", "description": "hpcc-js - DGrid2", - "main": "dist/index.js", - "module": "dist/index.es6", - "unpkg": "dist/index.min.js", - "jsdelivr": "dist/index.min.js", - "types": "types/index.d.ts", - "typesVersions": { - "<3.8": { - "*": [ - "types-3.4/index.d.ts" - ] + "type": "module", + "exports": { + ".": { + "types": "./types/index.d.ts", + "default": "./dist/index.js" } }, + "module": "./dist/index.js", + "browser": "./dist/index.js", + "types": "./types/index.d.ts", "files": [ "dist/*", + "src/*", "types/*", - "types-3.4/*", - "src/*" + "font-awesome/**/*" ], "scripts": { - "clean": "rimraf --glob lib* types dist *.tsbuildinfo", - "compile-es6": "tsc --module es6 --outDir ./lib-es6", - "compile-es6-watch": "npm run compile-es6 -- -w", - "compile-umd": "tsc --module umd --outDir ./lib-umd", - "compile-umd-watch": "npm run compile-umd -- -w", - "bundle": "rollup -c", - "bundle-watch": "npm run bundle -- -w", - "minimize": "terser dist/index.js -c -m --source-map \"content='dist/index.js.map',url='index.min.js.map'\" -o dist/index.min.js", - "gen-legacy-types": "downlevel-dts ./types ./types-3.4", - "build": "npm run compile-es6 && npm run bundle", - "watch": "npm-run-all compile-es6 -p compile-es6-watch bundle-watch", - "serve-vite": "vite --config ../../vite.config.js", + "clean": "rimraf --glob lib* types dist *.tsbuildinfo .turbo", + "bundle": "node esbuild.js", + "bundle-watch": "npm run bundle -- --development --watch", + "gen-types": "tsc --project tsconfig.json", + "gen-types-watch": "npm run gen-types -- --watch", + "build": "run-p gen-types bundle", "stamp": "node ../../node_modules/@hpcc-js/bundle/src/stamp.js", - "lint": "eslint src/**/*.ts", + "lint": "eslint ./src", + "lint-fix": "eslint --fix src/**/*.ts", "docs": "typedoc --options tdoptions.json .", - "update": "npx --yes npm-check-updates -u -t minor" + "test-browser": "vitest run --project browser", + "test": "vitest run", + "coverage": "vitest run --coverage", + "update": "npx --yes npm-check-updates -u -t minor", + "update-major": "npx --yes npm-check-updates -u" }, "dependencies": { - "@hpcc-js/common": "^2.73.0", - "@hpcc-js/preact-shim": "^2.18.0", - "@hpcc-js/util": "^2.53.0" + "@hpcc-js/common": "^3.0.0", + "@hpcc-js/util": "^3.0.0" }, "devDependencies": { - "@hpcc-js/bundle": "^2.12.0", - "react-data-grid": "7.0.0-canary.49", - "tslib": "2.7.0" + "@hpcc-js/esbuild-plugins": "^1.2.0", + "react-data-grid": "7.0.0-beta.47", + "react": "18.3.1", + "react-dom": "18.3.1" + }, + "peerDependencies": { + "react": "^17.0.0 || ^18.0.0", + "react-dom": "^17.0.0 || ^18.0.0" }, "repository": { "type": "git", @@ -59,4 +60,4 @@ "url": "https://github.com/hpcc-systems/Visualization/issues" }, "homepage": "https://github.com/hpcc-systems/Visualization" -} +} \ No newline at end of file diff --git a/packages/dgrid2/rollup.config.mjs b/packages/dgrid2/rollup.config.mjs deleted file mode 100644 index 9ea9f3a97c..0000000000 --- a/packages/dgrid2/rollup.config.mjs +++ /dev/null @@ -1,52 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ - -import { external, globals } from "@hpcc-js/bundle"; -import alias from "@rollup/plugin-alias"; -import commonjs from "@rollup/plugin-commonjs"; -import sourcemaps from "rollup-plugin-sourcemaps"; -import nodeResolve from "@rollup/plugin-node-resolve"; -import postcss from "rollup-plugin-postcss"; -import replace from "@rollup/plugin-replace"; - -import pkg from "./package.json" with { type: "json" }; - -export default { - input: "lib-es6/index", - external, - output: [{ - file: pkg.main, - format: "umd", - sourcemap: true, - globals, - name: pkg.name - }, { - file: pkg.module + ".js", - format: "es", - sourcemap: true, - globals, - name: pkg.name - }], - plugins: [ - alias({ - entries: [ - { find: "react", replacement: "preact/compat" }, - { find: "react/jsx-runtime", replacement: "preact/jsx-runtime" }, - { find: "react-dom", replacement: "preact/compat" }, - { find: "react-dom/test-utils", replacement: "preact/test-utils" }, - ] - }), - nodeResolve({ - preferBuiltins: true - }), - replace({ - preventAssignment: true, - "process.env.NODE_ENV": JSON.stringify("production") - }), - commonjs({}), - sourcemaps(), - postcss({ - extensions: [".css"], - minimize: true - }) - ] -}; diff --git a/packages/dgrid2/src/hooks.ts b/packages/dgrid2/src/hooks.ts index b09ee01b7e..1ddb29a24c 100644 --- a/packages/dgrid2/src/hooks.ts +++ b/packages/dgrid2/src/hooks.ts @@ -1,5 +1,5 @@ +import React from "react"; import { Widget } from "@hpcc-js/common"; -import * as React from "react"; export function useData(widget: Widget): [string[], Array[]] { // eslint-disable-next-line react-hooks/exhaustive-deps @@ -9,4 +9,3 @@ export function useData(widget: Widget): [string[], Array[]] { return [columns, data]; } - diff --git a/packages/dgrid2/src/index.ts b/packages/dgrid2/src/index.ts index 6080d9cbfd..123939a29f 100644 --- a/packages/dgrid2/src/index.ts +++ b/packages/dgrid2/src/index.ts @@ -1,2 +1,2 @@ -export * from "./__package__"; -export * from "./table"; +export * from "./__package__.ts"; +export * from "./table.ts"; diff --git a/packages/dgrid2/src/reactTable.tsx b/packages/dgrid2/src/reactTable.tsx index 9b2fac4426..acfafc776f 100644 --- a/packages/dgrid2/src/reactTable.tsx +++ b/packages/dgrid2/src/reactTable.tsx @@ -1,8 +1,10 @@ import * as React from "react"; import DataGrid, { Column, SelectColumn, SortColumn } from "react-data-grid"; import { format, timeFormat, timeParse } from "@hpcc-js/common"; -import { useData } from "./hooks"; -import type { Table } from "./table"; +import { useData } from "./hooks.ts"; +import type { Table } from "./table.ts"; + +import "react-data-grid/lib/styles.css"; export type QuerySortItem = { attribute: string, descending: boolean }; function copyAndSort(items: T[], attribute: string, descending?: boolean): T[] { diff --git a/packages/dgrid2/src/table.ts b/packages/dgrid2/src/table.ts index de98fb10fa..8c2fa50fbf 100644 --- a/packages/dgrid2/src/table.ts +++ b/packages/dgrid2/src/table.ts @@ -1,33 +1,21 @@ -import * as React from "react"; -import { HTMLWidget, publish } from "@hpcc-js/common"; -import { render, unmountComponentAtNode } from "react-dom"; -import { ReactTable } from "./reactTable"; +import React from "react"; +import { createRoot, Root } from "react-dom/client"; +import { HTMLWidget } from "@hpcc-js/common"; +import { ReactTable } from "./reactTable.tsx"; -import "../src/table.css"; +import "./table.css"; export type ColumnType = "boolean" | "number" | "string" | "time"; export class Table extends HTMLWidget { protected _div; + protected _root: Root; constructor() { super(); } - @publish("...empty...", "string", "No Data Message") - noDataMessage: publish; - @publish(false, "boolean", "Dark Mode") - darkMode: publish; - @publish(false, "boolean", "Multiple Selection") - multiSelect: publish; - @publish({}, "object", "Column Types (\"boolean\" | \"number\" | \"string\" | \"time\"") - columnTypes: publish; - @publish({}, "object", "Column Patterns") - columnPatterns: publish; - @publish({}, "object", "Column Formats") - columnFormats: publish; - columnType(column: string): ColumnType; columnType(column: string, type: ColumnType): this; columnType(column: string, type?: ColumnType): ColumnType | this { @@ -69,18 +57,20 @@ export class Table extends HTMLWidget { super.enter(domNode, element); this._div = element .append("div") + .style("display", "grid") ; + this._root = createRoot(this._div.node()); } update(domNode, element) { super.update(domNode, element); this._div.style("width", this.width() + "px"); this._div.style("height", this.height() + "px"); - render(React.createElement(ReactTable, { table: this }), this._div.node()); + this._root.render(React.createElement(ReactTable, { table: this })); } exit(domNode, element) { - unmountComponentAtNode(this._div.node()); + this._root.unmount(); this._div.remove(); super.exit(domNode, element); } @@ -90,3 +80,26 @@ export class Table extends HTMLWidget { } } Table.prototype._class += " dgrid2_Table"; + +export interface Table { + noDataMessage(): string; + noDataMessage(_: string): this; + darkMode(): boolean; + darkMode(_: boolean): this; + multiSelect(): boolean; + multiSelect(_: boolean): this; + columnTypes(): { [column: string]: ColumnType }; + columnTypes(_: { [column: string]: ColumnType }): this; + columnPatterns(): { [column: string]: string }; + columnPatterns(_: { [column: string]: string }): this; + columnFormats(): { [column: string]: string }; + columnFormats(_: { [column: string]: string }): this; +} + +Table.prototype.publish("noDataMessage", "...empty...", "string", "No Data Message"); +Table.prototype.publish("darkMode", false, "boolean", "Dark Mode"); +Table.prototype.publish("multiSelect", false, "boolean", "Multiple Selection"); +Table.prototype.publish("columnTypes", {}, "object", "Column Types (\"boolean\" | \"number\" | \"string\" | \"time\""); +Table.prototype.publish("columnPatterns", {}, "object", "Column Patterns"); +Table.prototype.publish("columnFormats", {}, "object", "Column Formats"); + diff --git a/packages/dgrid2/tests/dgrid2.browser.spec.ts b/packages/dgrid2/tests/dgrid2.browser.spec.ts new file mode 100644 index 0000000000..5c95cd6c36 --- /dev/null +++ b/packages/dgrid2/tests/dgrid2.browser.spec.ts @@ -0,0 +1,62 @@ +import * as dgrid2 from "@hpcc-js/dgrid2"; +import { Table } from "@hpcc-js/dgrid2"; +import { Class, HTMLWidget, SVGWidget } from "@hpcc-js/common"; +import { describe, it, expect } from "vitest"; +import { classDef, renderMedium, renderShort, renderSmall, renderWide } from "../../common/tests/index.ts"; + +const urlSearch: string = window.location.href.split("?")[1]; +const simple = { + ND: { + columns: ["Subject", "Year 1", "Year 2", "Year 3", "Year 4"], + data: [ + ["English", 5, 43, 41, 92], + ["English II", 17, 43, 83, 93], + ["English III", 6, 43, 64, 93], + ["Geography", 7, 45, 52, 83], + ["Geography II", 16, 73, 52, 83], + ["Geography III", 26, 83, 11, 72], + ["Science", 66, 60, 85, 6], + ["Science II", 46, 20, 53, 7], + ["Science III", 46, 20, 38, 7], + ["Math", 98, 30, 23, 13], + ["Math II", 76, 30, 34, 6], + ["Math III", 80, 30, 27, 8] + ] + }, + WordCloud: { + columns: ["Word", "Weight"], + words: ["Myriel", "Napoleon", "Mlle.Baptistine", "Mme.Magloire", "CountessdeLo", "Geborand", "Champtercier", "Cravatte", "Count", "OldMan", "Labarre", "Valjean", "Marguerite", "Mme.deR", "Isabeau", "Gervais", "Tholomyes", "Listolier", "Fameuil", "Blacheville", "Favourite", "Dahlia", "Zephine", "Fantine", "Mme.Thenardier", "Thenardier", "Cosette", "Javert", "Fauchelevent", "Bamatabois", "Perpetue", "Simplice", "Scaufflaire", "Woman1", "Judge", "Champmathieu", "Brevet", "Chenildieu", "Cochepaille", "Pontmercy", "Boulatruelle", "Eponine", "Anzelma", "Woman2", "MotherInnocent", "Gribier", "Jondrette", "Mme.Burgon", "Gavroche", "Gillenormand", "Magnon", "Mlle.Gillenormand", "Mme.Pontmercy", "Mlle.Vaubois", "Lt.Gillenormand", "Marius", "BaronessT", "Mabeuf", "Enjolras", "Combeferre", "Prouvaire", "Feuilly", "Courfeyrac", "Bahorel", "Bossuet", "Joly", "Grantaire", "MotherPlutarch", "Gueulemer", "Babet", "Claquesous", "Montparnasse", "Toussaint", "Child1", "Child2", "Brujon", "Mme.Hucheloup"] + } +}; +describe("@hpcc-js/dgrid2", () => { + for (const key in dgrid2) { + const item = (dgrid2 as any)[key]; + if (item) { + if (!urlSearch || urlSearch === item.prototype.constructor.name) { + describe(`${item.prototype?.constructor?.name}`, () => { + it("Simple", () => { + expect(true).to.be.true; + }); + if (item.prototype instanceof Class) { + classDef("dgrid2", item); + } + if (item.prototype instanceof HTMLWidget || item.prototype instanceof SVGWidget) { + switch (item.prototype.constructor) { + case Table: + renderMedium(new item.prototype.constructor() + .columns(simple.ND.columns) + .data(simple.ND.data) + ); + break; + + default: + it("Has render test", () => { + expect(false).to.be.true; + }); + } + } + }); + } + } + } +}); diff --git a/packages/dgrid2/tsconfig.json b/packages/dgrid2/tsconfig.json index 5e7941733d..f7c315bbc3 100644 --- a/packages/dgrid2/tsconfig.json +++ b/packages/dgrid2/tsconfig.json @@ -1,18 +1,26 @@ { - "extends": "../tsconfig.settings.json", "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib-umd", - "declarationDir": "./types", + "rootDir": "src", + "module": "NodeNext", + "target": "ESNext", + "resolveJsonModule": true, + "emitDeclarationOnly": true, + "declaration": true, + "declarationDir": "types", "jsx": "react", + "strict": false, + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false, "skipLibCheck": true, + "allowImportingTsExtensions": true, + "lib": [ + "DOM", + "ESNext", + "ES2020" + ] }, "include": [ - "./src/**/*" - ], - "references": [ - { - "path": "../common" - }, + "./src/index.ts" ] } \ No newline at end of file diff --git a/packages/dgrid2/vitest.workspace.ts b/packages/dgrid2/vitest.workspace.ts new file mode 100644 index 0000000000..fa7bb0720b --- /dev/null +++ b/packages/dgrid2/vitest.workspace.ts @@ -0,0 +1,6 @@ +import { defineWorkspace } from 'vitest/config'; +import baseWorkspace from '../../vitest.workspace.ts'; + +export default defineWorkspace([ + ...baseWorkspace +]) \ No newline at end of file