tslab-widgets 0.1.0 → 1.1.0

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.
Files changed (45) hide show
  1. package/LICENSE +170 -197
  2. package/dist/chart/chart.d.ts +10 -9
  3. package/dist/chart/chart.d.ts.map +1 -0
  4. package/dist/chart/chart.js +223 -85
  5. package/dist/chart/chart.js.map +1 -0
  6. package/dist/chart/plugins/tooltip.d.ts +32 -17
  7. package/dist/chart/plugins/tooltip.d.ts.map +1 -0
  8. package/dist/chart/plugins/tooltip.js +235 -64
  9. package/dist/chart/plugins/tooltip.js.map +1 -0
  10. package/dist/chart/plugins/trendLine.d.ts +5 -4
  11. package/dist/chart/plugins/trendLine.d.ts.map +1 -0
  12. package/dist/chart/plugins/trendLine.js +10 -4
  13. package/dist/chart/plugins/trendLine.js.map +1 -0
  14. package/dist/chart/plugins/verticalLine.d.ts +5 -4
  15. package/dist/chart/plugins/verticalLine.d.ts.map +1 -0
  16. package/dist/chart/plugins/verticalLine.js +43 -13
  17. package/dist/chart/plugins/verticalLine.js.map +1 -0
  18. package/dist/chart/plugins/volumeProfile.d.ts +31 -11
  19. package/dist/chart/plugins/volumeProfile.d.ts.map +1 -0
  20. package/dist/chart/plugins/volumeProfile.js +162 -24
  21. package/dist/chart/plugins/volumeProfile.js.map +1 -0
  22. package/dist/config/versions.d.ts +28 -0
  23. package/dist/config/versions.d.ts.map +1 -0
  24. package/dist/config/versions.js +41 -0
  25. package/dist/config/versions.js.map +1 -0
  26. package/dist/gauge/gauge.d.ts +9 -6
  27. package/dist/gauge/gauge.d.ts.map +1 -0
  28. package/dist/gauge/gauge.js +379 -40
  29. package/dist/gauge/gauge.js.map +1 -0
  30. package/dist/index.d.ts +8 -7
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +4 -3
  33. package/dist/index.js.map +1 -0
  34. package/dist/json/json.d.ts +1 -0
  35. package/dist/json/json.d.ts.map +1 -0
  36. package/dist/json/json.js +10 -6
  37. package/dist/json/json.js.map +1 -0
  38. package/dist/table/table.d.ts +9 -0
  39. package/dist/table/table.d.ts.map +1 -0
  40. package/dist/table/table.js +49 -0
  41. package/dist/table/table.js.map +1 -0
  42. package/package.json +49 -30
  43. package/readme.md +43 -7
  44. package/dist/csv/csv.d.ts +0 -5
  45. package/dist/csv/csv.js +0 -83
package/package.json CHANGED
@@ -1,17 +1,29 @@
1
1
  {
2
2
  "name": "tslab-widgets",
3
- "version": "0.1.0",
3
+ "version": "1.1.0",
4
4
  "description": "A set of widgets for ts-lab environment including financial charts",
5
5
  "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
6
15
  "scripts": {
7
- "build": "npx tsc",
8
- "lint": "npx eslint",
9
- "reset": "rm -rf node_modules && rm -rf dist && npm install"
16
+ "build": "rm -rf dist && npx tsc",
17
+ "prebuild": "npm run validate",
18
+ "validate": "tsx scripts/validate-versions.ts",
19
+ "reset": "rm -rf node_modules && rm -rf dist && npm install",
20
+ "format": "npx @biomejs/biome format --write",
21
+ "lint": "npx @biomejs/biome lint --write",
22
+ "check": "npx @biomejs/biome check --write"
10
23
  },
11
24
  "files": [
12
25
  "dist"
13
26
  ],
14
- "types": "dist/index.d.ts",
15
27
  "keywords": [
16
28
  "tslab",
17
29
  "jupyter",
@@ -34,7 +46,7 @@
34
46
  },
35
47
  "repository": {
36
48
  "type": "git",
37
- "url": "git+https://github.com/rodrigopivi/tslab-widgets"
49
+ "url": "git+https://github.com/rodrigopivi/tslab-widgets.git"
38
50
  },
39
51
  "bugs": {
40
52
  "url": "https://github.com/rodrigopivi/tslab-widgets/issues"
@@ -42,31 +54,38 @@
42
54
  "homepage": "https://github.com/rodrigopivi/tslab-widgets#readme",
43
55
  "private": false,
44
56
  "dependencies": {
45
- "tslab": "1.0.22"
57
+ "tslab": "^1.0.0"
46
58
  },
47
59
  "devDependencies": {
48
- "@babel/core": "7.25.2",
49
- "@babel/preset-react": "7.24.7",
50
- "@types/node": "22.4.1",
51
- "@types/react": "18.3.4",
52
- "@typescript-eslint/eslint-plugin": "7.16.0",
53
- "@typescript-eslint/parser": "7.16.0",
54
- "cspell": "8.14.2",
55
- "eslint": "8.57.0",
56
- "eslint-config-prettier": "9.1.0",
57
- "eslint-plugin-deprecation": "3.0.0",
58
- "eslint-plugin-import": "2.29.1",
59
- "eslint-plugin-perfectionist": "2.11.0",
60
- "eslint-plugin-react": "7.35.0",
61
- "eslint-plugin-react-hooks": "4.6.2",
62
- "eslint-plugin-simple-import-sort": "12.1.1",
63
- "eslint-plugin-unicorn": "54.0.0",
64
- "eslint-plugin-unused-imports": "3.2.0",
65
- "lightweight-charts": "4.2.0",
66
- "prettier": "3.3.3",
67
- "react": "18.3.1",
68
- "tslib": "2.6.3",
69
- "typescript": "5.5.4",
70
- "webpack-cli": "5.1.4"
60
+ "@babel/core": "7.28.5",
61
+ "@babel/preset-react": "7.28.5",
62
+ "@biomejs/biome": "2.3.10",
63
+ "@types/node": "25.0.3",
64
+ "@types/react": "^19.2.7",
65
+ "@types/react-dom": "^19.2.3",
66
+ "ag-charts-react": "13.0.0",
67
+ "ag-grid-react": "35.0.0",
68
+ "ag-grid-community": "35.0.0",
69
+ "cspell": "9.4.0",
70
+ "lightweight-charts": "5.1.0",
71
+ "react": "19.2.3",
72
+ "react-dom": "19.2.3",
73
+ "recharts": "3.6.0",
74
+ "tslib": "2.8.1",
75
+ "tsx": "^4.21.0",
76
+ "typescript": "5.9.3"
77
+ },
78
+ "peerDependencies": {
79
+ "react": ">=18.0.0",
80
+ "react-dom": ">=18.0.0",
81
+ "tslab": "^1.0.0"
82
+ },
83
+ "peerDependenciesMeta": {
84
+ "react": {
85
+ "optional": true
86
+ },
87
+ "react-dom": {
88
+ "optional": true
89
+ }
71
90
  }
72
91
  }
package/readme.md CHANGED
@@ -3,24 +3,60 @@
3
3
  </center>
4
4
 
5
5
  <blockquote>
6
- A set of widgets for tslab (the interactive programming environment on top of jupyter lab that supports typescript and javascript).
6
+ A library that brings rich, interactive data visualizations directly to Jupyter Notebooks through a TypeScript kernel bridging the gap between the expressive power of modern TypeScript charting libraries and the iterative, exploratory workflow of Jupyter.
7
7
  </blockquote>
8
8
  <hr />
9
9
  <br>
10
10
 
11
+ ## Overview
12
+
13
+ 🔧 **First-Class TypeScript Experience**: Designed specifically for TS kernels. Get full type checking, autocompletion (IntelliSense) for your chart configurations, and safe refactoring as you explore your data.
14
+
15
+ 📚 **Notebook-Native**: Visualizations render inline as notebook cell outputs. They are fully embedded in the document, making them ideal for creating reproducible analysis reports, interactive dashboards, and storytelling with data.
16
+
17
+ 🎯 **Leverage the TS Ecosystem**: Integrates with popular JavaScript visualization libraries.
18
+
19
+ ⚡ **Lightweight** - CDN-based dependencies for fast loading and no build step.
20
+
21
+ 📊 **Financial Charts** - Candlestick, line, area with crosshair and time-scale synchronization across multiple charts.
22
+
23
+ ✨ **Data Visualization** - Tables, charts, JSON tree viewer, gauge and more to come...
24
+
11
25
  ### Setup:
12
26
 
13
27
  - Install [tslab](https://github.com/yunabe/tslab)
14
- - `npm i tslab-widgets`
28
+ - `npm i -S tslab tslab-widgets tslib lightweight-charts`
15
29
 
16
30
  ### Widget list:
17
31
 
18
- - Chart (thanks to `lightweight-charts`)
19
- - CSV
20
- - Gauge
21
- - JSON
32
+ - **Chart** - Financial charts powered by `lightweight-charts` with plugins:
33
+ - Candlestick, Line, Area, Bar, Baseline, Histogram
34
+ - Tooltips, trend lines, volume profiles, vertical markers
35
+ - Multi-chart synchronization (crosshair + time scale)
36
+ - **CSV** - Responsive table viewer with auto-pairing layout
37
+ - **Gauge** - Circular progress/KPI indicators
38
+ - **JSON** - Expandable tree view for objects
39
+
40
+ Review the [example jupyter notebook](https://github.com/rodrigopivi/tslab-widgets/blob/main/example.ipynb).
41
+
42
+ ## CDN Strategy
43
+
44
+ tslab-widgets uses a **CDN-based approach** for runtime dependencies (React, lightweight-charts, etc.). This means:
45
+
46
+ - ✅ **No bundling overhead** - Dependencies loaded directly from esm.sh
47
+ - ✅ **Faster notebook loading** - Browser caches shared dependencies
48
+ - ✅ **Smaller package size** - No need to bundle React into the library
49
+ - ✅ **Centralized version management** - All CDN versions managed in `src/config/versions.ts`
50
+
51
+ ### Screenshots
52
+
53
+ <img width="1242" alt="Screenshot 2024-09-05 at 12 36 37 PM" src="https://github.com/user-attachments/assets/ab9a258c-059e-4bae-ac5b-6c753e885e70">
54
+
55
+ <img width="1025" alt="Screenshot 2024-09-05 at 12 37 29 PM" src="https://github.com/user-attachments/assets/1a8cd079-ae49-4cd4-b629-069cc7a0bb61">
56
+
57
+ ### Configure VSCode to use Typescript Kernel
22
58
 
23
- Review the [example jupyter notebook](https://github.com/rodrigopivi/tslab-widgets/blob/main/exampmle.ipynb).
59
+ Go to `Select Kernel` -> `Jupyter Kernel...` -> `Typescript`
24
60
 
25
61
  ### Author
26
62
 
package/dist/csv/csv.d.ts DELETED
@@ -1,5 +0,0 @@
1
- declare function csv(data: string[], options?: {
2
- customCss?: string;
3
- maxHeight?: number;
4
- }): void;
5
- export { csv };
package/dist/csv/csv.js DELETED
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.csv = void 0;
4
- const tslib_1 = require("tslib");
5
- const tslab = tslib_1.__importStar(require("tslab"));
6
- // https://github.com/marudhupandiyang/react-csv-to-table
7
- function csv(data, options) {
8
- const reactComponentId = `_csv_widget${Math.random().toString(36).substring(2, 9)}`;
9
- const html = `
10
- <style type="text/css">
11
- table.widget-csv-table {
12
- margin: auto !important;
13
- margin-bottom: 10px !important;
14
- > thead {
15
- background-color: #000;
16
- border: 1px solid #888 !important;
17
- }
18
- > tbody {
19
- border: 1px solid #888 !important;
20
- border-top: 0 !important;
21
- > tr:hover {
22
- background-color: #172F3F !important;
23
- }
24
- }
25
- }
26
- ${(options === null || options === void 0 ? void 0 : options.customCss) || ''}
27
- </style>
28
- <div id="${reactComponentId}" style="margin:auto;" />
29
- <script type="module">
30
- import React from "https://esm.sh/react@18.3.1";
31
- import ReactDOM from "https://esm.sh/react-dom@18.3.1";
32
- import { CsvToHtmlTable } from "https://esm.sh/react-csv-to-table@0.0.4";
33
- const h = React.createElement;
34
-
35
- const reactJupyterLabComponentId = "${reactComponentId}";
36
- const jupyterLabReactComponentContainer = document.getElementById("${reactComponentId}");
37
-
38
- const data = [${data.map((d) => JSON.stringify(d)).join(',')}];
39
- const csvWidgets = groupArrayIntoPairs(data);
40
- const rows = csvWidgets.map((rowDataPair, idx) => {
41
- const cid1 = reactJupyterLabComponentId + '-0';
42
- const cid2 = reactJupyterLabComponentId + '-1';
43
- const csvTableRowStyle = {
44
- display: 'flex',
45
- flexDirection: 'column',
46
- alignSelf: 'baseline',
47
- ${(options === null || options === void 0 ? void 0 : options.maxHeight) ? `maxHeight:${options.maxHeight},overflowY: "scroll"` : ''}
48
- };
49
- const key = 'row-' + idx;
50
- return (
51
-
52
- h('div', { key, className: 'csv-' + key, style: { display: 'flex', flexDirection: 'row', margin: 'auto' }}, [
53
- h('div', { className: 'csv-col-0', style: csvTableRowStyle },
54
- h(CsvToHtmlTable, { data: rowDataPair[0], csvDelimiter: ',', tableClassName: 'widget-csv-table' })
55
- ),
56
- h('div', { className: 'csv-col-1', style: csvTableRowStyle },
57
- rowDataPair[1]
58
- ? h(CsvToHtmlTable, { data: rowDataPair[1], csvDelimiter: ',', tableClassName: 'widget-csv-table' })
59
- : null,
60
- ),
61
- ])
62
- );
63
- });
64
-
65
- ReactDOM.render(
66
- h('div', { style: { display: 'flex', flexDirection: 'column' }}, rows),
67
- jupyterLabReactComponentContainer
68
- );
69
-
70
- function groupArrayIntoPairs(arr) {
71
- const pairs = [];
72
- for (let i = 0; i < arr.length; i += 2) {
73
- const pair = [arr[i], arr[i + 1]];
74
- pairs.push(pair);
75
- }
76
- return pairs;
77
- }
78
-
79
- </script>
80
- `;
81
- tslab.display.html(html);
82
- }
83
- exports.csv = csv;