tslab-widgets 0.1.0 → 1.0.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 (43) 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 +219 -79
  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 +37 -0
  23. package/dist/config/versions.d.ts.map +1 -0
  24. package/dist/config/versions.js +43 -0
  25. package/dist/config/versions.js.map +1 -0
  26. package/dist/csv/csv.d.ts +1 -0
  27. package/dist/csv/csv.d.ts.map +1 -0
  28. package/dist/csv/csv.js +8 -6
  29. package/dist/csv/csv.js.map +1 -0
  30. package/dist/gauge/gauge.d.ts +1 -0
  31. package/dist/gauge/gauge.d.ts.map +1 -0
  32. package/dist/gauge/gauge.js +7 -5
  33. package/dist/gauge/gauge.js.map +1 -0
  34. package/dist/index.d.ts +8 -7
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +1 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/json/json.d.ts +1 -0
  39. package/dist/json/json.d.ts.map +1 -0
  40. package/dist/json/json.js +5 -3
  41. package/dist/json/json.js.map +1 -0
  42. package/package.json +46 -31
  43. package/readme.md +54 -6
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.gauge = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const tslab = tslib_1.__importStar(require("tslab"));
6
+ const versions_1 = require("../config/versions");
6
7
  // https://www.npmjs.com/package/react-gauge-chart
7
8
  function gauge(width = 200, props) {
8
9
  var _a;
@@ -15,9 +16,9 @@ function gauge(width = 200, props) {
15
16
  }
16
17
  </style>
17
18
  <script type="module">
18
- import React from "https://esm.sh/react@18.3.1";
19
- import ReactDOM from "https://esm.sh/react-dom@18.3.1";
20
- import GaugeChart from "https://esm.sh/react-gauge-chart@0.5.1";
19
+ import React from "${versions_1.CDN_URLS.react}";
20
+ import ReactDOM from "${versions_1.CDN_URLS.reactDom}";
21
+ import GaugeChart from "${versions_1.CDN_URLS.reactGaugeChart}";
21
22
  const h = React.createElement;
22
23
 
23
24
  const reactJupyterLabComponentId = "${reactComponentId}";
@@ -39,12 +40,12 @@ function gauge(width = 200, props) {
39
40
  };
40
41
  ReactDOM.render(
41
42
  h('div', { style: styles.wrapper }, [
42
- h('div', { style: styles.title }, '${(_a = props.title) !== null && _a !== void 0 ? _a : ''}'),
43
+ h('div', { style: styles.title }, '${(_a = props.title) !== null && _a !== void 0 ? _a : ""}'),
43
44
  h(GaugeChart, {
44
45
  id: 'rg-${reactComponentId}',
45
46
  colors: ['#D10363', '#4CCD99'],
46
47
  needleColor: '#888',
47
- ${props.score ? `formatTextValue: value => '${props.score}',` : ''}
48
+ ${props.score ? `formatTextValue: value => '${props.score}',` : ""}
48
49
  ...props,
49
50
  }),
50
51
  h('div', { style: styles.legend }, '${props.legend}'),
@@ -57,3 +58,4 @@ function gauge(width = 200, props) {
57
58
  tslab.display.html(html);
58
59
  }
59
60
  exports.gauge = gauge;
61
+ //# sourceMappingURL=gauge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gauge.js","sourceRoot":"","sources":["../../src/gauge/gauge.ts"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAE/B,iDAA8C;AAE9C,kDAAkD;AAClD,SAAS,KAAK,CACb,KAAK,GAAG,GAAG,EACX,KAOC;;IAED,MAAM,gBAAgB,GAAG,gBAAgB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACtF,MAAM,IAAI,GAAG;eACC,gBAAgB;;;;;;;2BAOJ,mBAAQ,CAAC,KAAK;8BACX,mBAAQ,CAAC,QAAQ;gCACf,mBAAQ,CAAC,eAAe;;;4CAGZ,gBAAgB;2EACe,gBAAgB;kCACzD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;;;oBAGnC,KAAK;;;;;;;;;;;;;;+CAcsB,MAAA,KAAK,CAAC,KAAK,mCAAI,EAAE;;sBAE1C,gBAAgB;;;cAGxB,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,8BAA8B,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE;;;gDAG9B,KAAK,CAAC,MAAM;;;;;;GAMzD,CAAC;IACH,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAEQ,sBAAK"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export { chart } from './chart/chart';
2
- export { csv } from './csv/csv';
3
- export { gauge } from './gauge/gauge';
4
- export { json } from './json/json';
5
- export type { IPoint } from './chart/plugins/trendLine';
6
- export type { IVertLineOptions } from './chart/plugins/verticalLine';
7
- export type { IVolumeProfileData } from './chart/plugins/volumeProfile';
1
+ export { chart } from "./chart/chart";
2
+ export type { IPoint } from "./chart/plugins/trendLine";
3
+ export type { IVertLineOptions } from "./chart/plugins/verticalLine";
4
+ export type { IVolumeProfileData } from "./chart/plugins/volumeProfile";
5
+ export { csv } from "./csv/csv";
6
+ export { gauge } from "./gauge/gauge";
7
+ export { json } from "./json/json";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,YAAY,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -9,3 +9,4 @@ var gauge_1 = require("./gauge/gauge");
9
9
  Object.defineProperty(exports, "gauge", { enumerable: true, get: function () { return gauge_1.gauge; } });
10
10
  var json_1 = require("./json/json");
11
11
  Object.defineProperty(exports, "json", { enumerable: true, get: function () { return json_1.json; } });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AAId,iCAAgC;AAAvB,0FAAA,GAAG,OAAA;AACZ,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,oCAAmC;AAA1B,4FAAA,IAAI,OAAA"}
@@ -4,3 +4,4 @@ declare function json<T extends object>(opts: {
4
4
  width?: number;
5
5
  }): void;
6
6
  export { json };
7
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/json/json.ts"],"names":[],"mappings":"AAIA,iBAAS,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE;IACrC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,QAyBA;AAED,OAAO,EAAE,IAAI,EAAE,CAAC"}
package/dist/json/json.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.json = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const tslab = tslib_1.__importStar(require("tslab"));
6
+ const versions_1 = require("../config/versions");
6
7
  function json(opts) {
7
8
  const width = opts.width || 400;
8
9
  const height = opts.height || 200;
@@ -13,9 +14,9 @@ function json(opts) {
13
14
  style="width:${width + 50}px;height:${height + 50}px;margin:auto;max-height:${height + 50}px;overflow:scroll;">
14
15
  </div>
15
16
  <script type="module">
16
- import React from "https://esm.sh/react@18.3.1";
17
- import ReactDOM from "https://esm.sh/react-dom@18.3.1";
18
- import ReactJsonTree from "https://esm.sh/react-json-tree@0.15.0";
17
+ import React from "${versions_1.CDN_URLS.react}";
18
+ import ReactDOM from "${versions_1.CDN_URLS.reactDom}";
19
+ import ReactJsonTree from "${versions_1.CDN_URLS.reactJsonTree}";
19
20
 
20
21
  const reactJupyterLabComponentId = "${reactComponentId}";
21
22
  const jupyterLabReactComponentContainer = document.getElementById("${reactComponentId}");
@@ -30,3 +31,4 @@ function json(opts) {
30
31
  tslab.display.html(html);
31
32
  }
32
33
  exports.json = json;
34
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/json/json.ts"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAE/B,iDAA8C;AAE9C,SAAS,IAAI,CAAmB,IAI/B;IACA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC;IAChC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC;IAClC,MAAM,gBAAgB,GAAG,eAAe,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACrF,MAAM,IAAI,GAAG;;YAEF,gBAAgB;qBACP,KAAK,GAAG,EAAE,aAAa,MAAM,GAAG,EAAE,6BAA6B,MAAM,GAAG,EAAE;;;2BAGpE,mBAAQ,CAAC,KAAK;8BACX,mBAAQ,CAAC,QAAQ;mCACZ,mBAAQ,CAAC,aAAa;;4CAEb,gBAAgB;2EACe,gBAAgB;iCAC1D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;GAOvD,CAAC;IACH,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAEQ,oBAAI"}
package/package.json CHANGED
@@ -1,17 +1,29 @@
1
1
  {
2
2
  "name": "tslab-widgets",
3
- "version": "0.1.0",
3
+ "version": "1.0.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,34 @@
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": "^18.3.0",
65
+ "@types/react-dom": "^18.3.0",
66
+ "cspell": "9.4.0",
67
+ "lightweight-charts": "5.1.0",
68
+ "react": "^18.3.1",
69
+ "react-dom": "^18.3.1",
70
+ "tslib": "2.8.1",
71
+ "tsx": "^4.21.0",
72
+ "typescript": "5.9.3"
73
+ },
74
+ "peerDependencies": {
75
+ "react": ">=18.0.0",
76
+ "react-dom": ">=18.0.0",
77
+ "tslab": "^1.0.0"
78
+ },
79
+ "peerDependenciesMeta": {
80
+ "react": {
81
+ "optional": true
82
+ },
83
+ "react-dom": {
84
+ "optional": true
85
+ }
71
86
  }
72
- }
87
+ }
package/readme.md CHANGED
@@ -8,19 +8,67 @@
8
8
  <hr />
9
9
  <br>
10
10
 
11
+ ## Features
12
+
13
+ ✨ **Financial Charts** - Candlestick, line, area, bar charts with real-time sync
14
+ 📊 **Data Visualization** - CSV tables, JSON tree viewer, gauge charts
15
+ 🎯 **Chart Sync** - Automatic crosshair and time-scale synchronization across multiple charts
16
+ 🔧 **Type-Safe** - Full TypeScript support with comprehensive type definitions
17
+ ⚡ **Lightweight** - CDN-based dependencies for fast loading
18
+
11
19
  ### Setup:
12
20
 
13
21
  - Install [tslab](https://github.com/yunabe/tslab)
14
- - `npm i tslab-widgets`
22
+ - `npm i -S tslab tslab-widgets`
23
+ - Optional dev dependencies: `npm i -D lightweight-charts tslib react react-dom`
24
+ - `npm install -g tslab`
25
+ - `npm i -S tslab tslab-widgets`
15
26
 
16
27
  ### Widget list:
17
28
 
18
- - Chart (thanks to `lightweight-charts`)
19
- - CSV
20
- - Gauge
21
- - JSON
29
+ - **Chart** - Financial charts powered by `lightweight-charts` with plugins:
30
+ - Candlestick, Line, Area, Bar, Baseline, Histogram
31
+ - Tooltips, trend lines, volume profiles, vertical markers
32
+ - Multi-chart synchronization (crosshair + time scale)
33
+ - **CSV** - Responsive table viewer with auto-pairing layout
34
+ - **Gauge** - Circular progress/KPI indicators
35
+ - **JSON** - Expandable tree view for objects
36
+
37
+ Review the [example jupyter notebook](https://github.com/rodrigopivi/tslab-widgets/blob/main/example.ipynb).
38
+
39
+ ## CDN Strategy
40
+
41
+ tslab-widgets uses a **CDN-based approach** for runtime dependencies (React, lightweight-charts, etc.). This means:
42
+
43
+ - ✅ **No bundling overhead** - Dependencies loaded directly from esm.sh
44
+ - ✅ **Faster notebook loading** - Browser caches shared dependencies
45
+ - ✅ **Smaller package size** - No need to bundle React into the library
46
+ - ✅ **Centralized version management** - All CDN versions managed in `src/config/versions.ts`
47
+
48
+ ### For Contributors: Updating CDN Versions
49
+
50
+ ```typescript
51
+ // Edit src/config/versions.ts
52
+ export const CDN_VERSIONS = {
53
+ react: "19.0.0", // Update version here
54
+ reactDom: "19.0.0",
55
+ lightweightCharts: "5.1.0",
56
+ // ...
57
+ };
58
+ ```
59
+
60
+ Then update corresponding versions in package.json devDependencies and run:
61
+
62
+ ```bash
63
+ npm run validate # Ensures versions match
64
+ npm run build
65
+ ```
66
+
67
+ ### Screenshots
68
+
69
+ <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">
22
70
 
23
- Review the [example jupyter notebook](https://github.com/rodrigopivi/tslab-widgets/blob/main/exampmle.ipynb).
71
+ <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">
24
72
 
25
73
  ### Author
26
74