tslab-widgets 1.0.0 → 1.2.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 (49) hide show
  1. package/README.md +100 -0
  2. package/dist/barchart/barchart.d.ts +44 -0
  3. package/dist/barchart/barchart.d.ts.map +1 -0
  4. package/dist/barchart/barchart.js +201 -0
  5. package/dist/barchart/barchart.js.map +1 -0
  6. package/dist/chart/chart.d.ts.map +1 -1
  7. package/dist/chart/chart.js +5 -7
  8. package/dist/chart/chart.js.map +1 -1
  9. package/dist/chart/plugins/tooltip.d.ts.map +1 -1
  10. package/dist/chart/plugins/tooltip.js +2 -70
  11. package/dist/chart/plugins/tooltip.js.map +1 -1
  12. package/dist/config/versions.d.ts +14 -23
  13. package/dist/config/versions.d.ts.map +1 -1
  14. package/dist/config/versions.js +17 -19
  15. package/dist/config/versions.js.map +1 -1
  16. package/dist/gauge/gauge.d.ts +20 -6
  17. package/dist/gauge/gauge.d.ts.map +1 -1
  18. package/dist/gauge/gauge.js +378 -39
  19. package/dist/gauge/gauge.js.map +1 -1
  20. package/dist/index.d.ts +9 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +11 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/json/json.d.ts +7 -0
  25. package/dist/json/json.d.ts.map +1 -1
  26. package/dist/json/json.js +26 -9
  27. package/dist/json/json.js.map +1 -1
  28. package/dist/layout/row.d.ts +48 -0
  29. package/dist/layout/row.d.ts.map +1 -0
  30. package/dist/layout/row.js +65 -0
  31. package/dist/layout/row.js.map +1 -0
  32. package/dist/pie/pie.d.ts +25 -0
  33. package/dist/pie/pie.d.ts.map +1 -0
  34. package/dist/pie/pie.js +171 -0
  35. package/dist/pie/pie.js.map +1 -0
  36. package/dist/scatter/scatter.d.ts +36 -0
  37. package/dist/scatter/scatter.d.ts.map +1 -0
  38. package/dist/scatter/scatter.js +193 -0
  39. package/dist/scatter/scatter.js.map +1 -0
  40. package/dist/table/table.d.ts +16 -0
  41. package/dist/table/table.d.ts.map +1 -0
  42. package/dist/table/table.js +56 -0
  43. package/dist/table/table.js.map +1 -0
  44. package/package.json +10 -6
  45. package/dist/csv/csv.d.ts +0 -6
  46. package/dist/csv/csv.d.ts.map +0 -1
  47. package/dist/csv/csv.js +0 -85
  48. package/dist/csv/csv.js.map +0 -1
  49. package/readme.md +0 -77
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scatter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /** biome-ignore-all lint/style/useTemplate: custom render */
6
+ const tslab = tslib_1.__importStar(require("tslab"));
7
+ const versions_1 = require("../config/versions");
8
+ function generateScatterHtml(config) {
9
+ const reactComponentId = `_scatter_widget${Math.random().toString(36).substring(2, 9)}`;
10
+ const { series, width, height = 400, title, subtitle, showLegend = true, showTooltip = true, xAxisTitle, yAxisTitle, xAxisFormatter, yAxisFormatter, } = config;
11
+ const serializedSeries = JSON.stringify(series);
12
+ return `
13
+ <div id="${reactComponentId}" style="display: flex; flex: 1;justify-content: center;">
14
+ <div style="padding: 20px; background: #2a2a2a; color: #fff; text-align: center; border-radius: 8px;">
15
+ <p style="margin: 0; font-size: 14px;">Loading chart...</p>
16
+ <p style="margin: 5px 0 0 0; font-size: 12px; color: #888;">If this message persists, there may be a module loading issue</p>
17
+ </div>
18
+ </div>
19
+ <script type="module">
20
+ import React from "${versions_1.CDN_URLS.react}";
21
+ import ReactDOM from "${versions_1.CDN_URLS.reactDom}";
22
+ import { AllCommunityModule, ModuleRegistry } from "https://esm.sh/ag-charts-community@13.0.0";
23
+ import { AgCharts } from "${versions_1.CDN_URLS.agChartsReact}";
24
+
25
+ const h = React.createElement;
26
+
27
+ ModuleRegistry.registerModules([AllCommunityModule]);
28
+
29
+ const seriesData = ${serializedSeries};
30
+ const showLegend = ${showLegend};
31
+ const showTooltip = ${showTooltip};
32
+ const title = "${title || ""}";
33
+ const subtitle = "${subtitle || ""}";
34
+ const xAxisTitle = "${xAxisTitle || ""}";
35
+ const yAxisTitle = "${yAxisTitle || ""}";
36
+ const maxWidth = ${width ? '"' + width.toString() + 'px"' : undefined};
37
+
38
+ // Default colors for series
39
+ const DEFAULT_COLORS = [
40
+ "#8884d8",
41
+ "#82ca9d",
42
+ "#ffc658",
43
+ "#ff7c7c",
44
+ "#8dd1e1",
45
+ "#d084d0",
46
+ "#ffb347",
47
+ "#a8e6cf"
48
+ ];
49
+
50
+ function getSeriesColor(series, index) {
51
+ return series.fill || DEFAULT_COLORS[index % DEFAULT_COLORS.length];
52
+ }
53
+
54
+ function buildSeries() {
55
+ return seriesData.map((series, index) => ({
56
+ type: 'scatter',
57
+ title: series.title,
58
+ data: series.data,
59
+ xKey: series.xKey,
60
+ xName: series.xName || series.xKey,
61
+ yKey: series.yKey,
62
+ yName: series.yName || series.yKey,
63
+ fill: getSeriesColor(series, index),
64
+ size: 6,
65
+ shape: series.shape || 'circle',
66
+ }));
67
+ }
68
+
69
+ function ScatterComponent() {
70
+ const series = buildSeries();
71
+
72
+ const chartOptions = {
73
+ theme: {
74
+ palette: {
75
+ fills: seriesData.map((s, index) => getSeriesColor(s, index)),
76
+ strokes: seriesData.map((s, index) => getSeriesColor(s, index)),
77
+ },
78
+ overrides: {
79
+ common: {
80
+ background: {
81
+ fill: 'transparent',
82
+ },
83
+ title: {
84
+ color: '#ffffff',
85
+ fontSize: 16,
86
+ },
87
+ subtitle: {
88
+ color: '#cccccc',
89
+ fontSize: 14,
90
+ },
91
+ legend: {
92
+ item: {
93
+ label: {
94
+ color: '#e0e0e0',
95
+ fontSize: 12,
96
+ },
97
+ },
98
+ },
99
+ },
100
+ scatter: {
101
+ axes: {
102
+ number: {
103
+ label: {
104
+ color: '#e0e0e0',
105
+ fontSize: 12,
106
+ },
107
+ line: {
108
+ color: '#555555',
109
+ },
110
+ gridLine: {
111
+ style: [{
112
+ stroke: '#444444',
113
+ lineDash: [5, 5],
114
+ }],
115
+ },
116
+ title: {
117
+ color: '#ffffff',
118
+ fontSize: 14,
119
+ },
120
+ },
121
+ },
122
+ },
123
+ },
124
+ },
125
+ title: title ? {
126
+ text: title,
127
+ } : undefined,
128
+ subtitle: subtitle ? {
129
+ text: subtitle,
130
+ } : undefined,
131
+ series: series,
132
+ axes: {
133
+ x: {
134
+ type: 'number',
135
+ position: 'bottom',
136
+ title: xAxisTitle ? {
137
+ text: xAxisTitle,
138
+ } : undefined,
139
+ label: ${xAxisFormatter ? `{ formatter: ${xAxisFormatter} }` : "undefined"},
140
+ },
141
+ y: {
142
+ type: 'number',
143
+ position: 'left',
144
+ title: yAxisTitle ? {
145
+ text: yAxisTitle,
146
+ } : undefined,
147
+ label: ${yAxisFormatter ? `{ formatter: ${yAxisFormatter} }` : "undefined"},
148
+ },
149
+ },
150
+ legend: {
151
+ enabled: showLegend,
152
+ position: 'bottom',
153
+ },
154
+ };
155
+
156
+ return h("div", {
157
+ style: {
158
+ textAlign: "center",
159
+ background: "#2a2a2a",
160
+ padding: "20px",
161
+ borderRadius: "8px",
162
+ width: "100%",
163
+ boxSizing: "border-box",
164
+ maxWidth,
165
+ }
166
+ }, [
167
+ h(AgCharts, {
168
+ options: chartOptions,
169
+ style: {
170
+ width: "100%",
171
+ maxWidth,
172
+ height: '${height}px',
173
+ },
174
+ })
175
+ ]);
176
+ }
177
+
178
+ const jupyterLabReactComponentContainer = document.getElementById("${reactComponentId}");
179
+
180
+ if (jupyterLabReactComponentContainer) {
181
+ const root = ReactDOM.createRoot(jupyterLabReactComponentContainer);
182
+ root.render(h(ScatterComponent));
183
+ }
184
+ </script>
185
+ `;
186
+ }
187
+ function scatter(config) {
188
+ const html = generateScatterHtml(config);
189
+ tslab.display.html(html);
190
+ }
191
+ exports.scatter = scatter;
192
+ scatter.html = (config) => generateScatterHtml(config);
193
+ //# sourceMappingURL=scatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scatter.js","sourceRoot":"","sources":["../../src/scatter/scatter.ts"],"names":[],"mappings":";;;;AAAA,6DAA6D;AAC7D,qDAA+B;AAC/B,iDAA8C;AAkC9C,SAAS,mBAAmB,CAAC,MAAsB;IAClD,MAAM,gBAAgB,GAAG,kBAAkB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACxF,MAAM,EACL,MAAM,EACN,KAAK,EACL,MAAM,GAAG,GAAG,EACZ,KAAK,EACL,QAAQ,EACR,UAAU,GAAG,IAAI,EACjB,WAAW,GAAG,IAAI,EAClB,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,GACd,GAAG,MAAM,CAAC;IAEX,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEhD,OAAO;eACO,gBAAgB;;;;;;;2BAOJ,mBAAQ,CAAC,KAAK;8BACX,mBAAQ,CAAC,QAAQ;;kCAEb,mBAAQ,CAAC,aAAa;;;;;;2BAM7B,gBAAgB;2BAChB,UAAU;4BACT,WAAW;uBAChB,KAAK,IAAI,EAAE;0BACR,QAAQ,IAAI,EAAE;4BACZ,UAAU,IAAI,EAAE;4BAChB,UAAU,IAAI,EAAE;yBACnB,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAuGpD,cAAc,CAAC,CAAC,CAAC,gBAAgB,cAAc,IAAI,CAAC,CAAC,CAAC,WAAW;;;;;;;;uBAQjE,cAAc,CAAC,CAAC,CAAC,gBAAgB,cAAc,IAAI,CAAC,CAAC,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;yBAyB/D,MAAM;;;;;;2EAM4C,gBAAgB;;;;;;;GAOxF,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,MAAsB;IACtC,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACzC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAIQ,0BAAO;AAFhB,OAAO,CAAC,IAAI,GAAG,CAAC,MAAsB,EAAU,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { GridOptions } from "ag-grid-community";
2
+ type RequiredFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
3
+ declare function table(params: {
4
+ options: RequiredFields<GridOptions, "rowData">;
5
+ height?: number;
6
+ width?: number;
7
+ }): void;
8
+ declare namespace table {
9
+ var html: (params: {
10
+ options: RequiredFields<GridOptions<any>, "rowData">;
11
+ height?: number | undefined;
12
+ width?: number | undefined;
13
+ }) => string;
14
+ }
15
+ export { table };
16
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/table/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAsDrE,iBAAS,KAAK,CAAC,MAAM,EAAE;IACtB,OAAO,EAAE,cAAc,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CAGP;kBAPQ,KAAK;;;;;;;AAed,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.table = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const tslab = tslib_1.__importStar(require("tslab"));
6
+ const versions_1 = require("../config/versions");
7
+ function generateTableHtml(params) {
8
+ const width = params.width || 550;
9
+ const height = params.height || 330;
10
+ const reactComponentId = `_table_widget${Math.random().toString(36).substring(2, 9)}`;
11
+ if (!params.options.columnDefs &&
12
+ params.options.rowData &&
13
+ params.options.rowData.length > 0) {
14
+ params.options.columnDefs = Object.keys(params.options.rowData[0]).map((key) => ({ field: key, filter: true, sortable: true }));
15
+ }
16
+ return `
17
+ <div id="${reactComponentId}" />
18
+
19
+ <link rel="stylesheet" href="${versions_1.CDN_URLS.agGridStyles}" />
20
+ <link rel="stylesheet" href="${versions_1.CDN_URLS.agGridThemeAlpine}" />
21
+
22
+ <script type="module">
23
+ import React from "${versions_1.CDN_URLS.react}";
24
+ import ReactDOM from "${versions_1.CDN_URLS.reactDom}";
25
+
26
+ import { AllCommunityModule, ModuleRegistry, themeBalham, colorSchemeDarkBlue } from "${versions_1.CDN_URLS.agGridCommunity}";
27
+ ModuleRegistry.registerModules([AllCommunityModule]);
28
+
29
+ import { AgGridReact } from "${versions_1.CDN_URLS.agGridReact}";
30
+
31
+ const h = React.createElement;
32
+ const reactJupyterLabComponentId = "${reactComponentId}";
33
+ const jupyterLabReactComponentContainer = document.getElementById("${reactComponentId}");
34
+ const options = JSON.parse('${JSON.stringify(params.options)}');
35
+ const theme = themeBalham.withPart(colorSchemeDarkBlue);
36
+ const gridOptions = { theme, ...options };
37
+
38
+ if (jupyterLabReactComponentContainer) {
39
+ const root = ReactDOM.createRoot(jupyterLabReactComponentContainer);
40
+ root.render(
41
+ h('div', { style: { width: ${width}, height: ${height}, margin: 'auto' }}, [
42
+ h(AgGridReact, { gridOptions })
43
+ ])
44
+ );
45
+ }
46
+
47
+ </script>
48
+ `;
49
+ }
50
+ function table(params) {
51
+ const html = generateTableHtml(params);
52
+ tslab.display.html(html);
53
+ }
54
+ exports.table = table;
55
+ table.html = (params) => generateTableHtml(params);
56
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/table/table.ts"],"names":[],"mappings":";;;;AACA,qDAA+B;AAC/B,iDAA8C;AAI9C,SAAS,iBAAiB,CAAC,MAI1B;IACA,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,GAAG,CAAC;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC;IACpC,MAAM,gBAAgB,GAAG,gBAAgB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACtF,IACC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU;QAC1B,MAAM,CAAC,OAAO,CAAC,OAAO;QACtB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAChC;QACD,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CACrE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CACvD,CAAC;KACF;IACD,OAAO;eACO,gBAAgB;;mCAEI,mBAAQ,CAAC,YAAY;mCACrB,mBAAQ,CAAC,iBAAiB;;;2BAGlC,mBAAQ,CAAC,KAAK;8BACX,mBAAQ,CAAC,QAAQ;;8FAE+C,mBAAQ,CAAC,eAAe;;;qCAGjF,mBAAQ,CAAC,WAAW;;;4CAGb,gBAAgB;2EACe,gBAAgB;oCACvD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;;;;;;;uCAO3B,KAAK,aAAa,MAAM;;;;;;;GAO5D,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,MAId;IACA,MAAM,IAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACvC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAQQ,sBAAK;AANd,KAAK,CAAC,IAAI,GAAG,CAAC,MAIb,EAAU,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tslab-widgets",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "A set of widgets for ts-lab environment including financial charts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -61,12 +61,16 @@
61
61
  "@babel/preset-react": "7.28.5",
62
62
  "@biomejs/biome": "2.3.10",
63
63
  "@types/node": "25.0.3",
64
- "@types/react": "^18.3.0",
65
- "@types/react-dom": "^18.3.0",
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",
66
69
  "cspell": "9.4.0",
67
70
  "lightweight-charts": "5.1.0",
68
- "react": "^18.3.1",
69
- "react-dom": "^18.3.1",
71
+ "react": "19.2.3",
72
+ "react-dom": "19.2.3",
73
+ "recharts": "3.6.0",
70
74
  "tslib": "2.8.1",
71
75
  "tsx": "^4.21.0",
72
76
  "typescript": "5.9.3"
@@ -84,4 +88,4 @@
84
88
  "optional": true
85
89
  }
86
90
  }
87
- }
91
+ }
package/dist/csv/csv.d.ts DELETED
@@ -1,6 +0,0 @@
1
- declare function csv(data: string[], options?: {
2
- customCss?: string;
3
- maxHeight?: number;
4
- }): void;
5
- export { csv };
6
- //# sourceMappingURL=csv.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../src/csv/csv.ts"],"names":[],"mappings":"AAKA,iBAAS,GAAG,CACX,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,QA4EpD;AAED,OAAO,EAAE,GAAG,EAAE,CAAC"}
package/dist/csv/csv.js DELETED
@@ -1,85 +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
- const versions_1 = require("../config/versions");
7
- // https://github.com/marudhupandiyang/react-csv-to-table
8
- function csv(data, options) {
9
- const reactComponentId = `_csv_widget${Math.random().toString(36).substring(2, 9)}`;
10
- const html = `
11
- <style type="text/css">
12
- table.widget-csv-table {
13
- margin: auto !important;
14
- margin-bottom: 10px !important;
15
- > thead {
16
- background-color: #000;
17
- border: 1px solid #888 !important;
18
- }
19
- > tbody {
20
- border: 1px solid #888 !important;
21
- border-top: 0 !important;
22
- > tr:hover {
23
- background-color: #172F3F !important;
24
- }
25
- }
26
- }
27
- ${(options === null || options === void 0 ? void 0 : options.customCss) || ""}
28
- </style>
29
- <div id="${reactComponentId}" style="margin:auto;" />
30
- <script type="module">
31
- import React from "${versions_1.CDN_URLS.react}";
32
- import ReactDOM from "${versions_1.CDN_URLS.reactDom}";
33
- import { CsvToHtmlTable } from "${versions_1.CDN_URLS.reactCsvToTable}";
34
- const h = React.createElement;
35
-
36
- const reactJupyterLabComponentId = "${reactComponentId}";
37
- const jupyterLabReactComponentContainer = document.getElementById("${reactComponentId}");
38
-
39
- const data = [${data.map((d) => JSON.stringify(d)).join(",")}];
40
- const csvWidgets = groupArrayIntoPairs(data);
41
- const rows = csvWidgets.map((rowDataPair, idx) => {
42
- const cid1 = reactJupyterLabComponentId + '-0';
43
- const cid2 = reactJupyterLabComponentId + '-1';
44
- const csvTableRowStyle = {
45
- display: 'flex',
46
- flexDirection: 'column',
47
- alignSelf: 'baseline',
48
- ${(options === null || options === void 0 ? void 0 : options.maxHeight) ? `maxHeight:${options.maxHeight},overflowY: "scroll"` : ""}
49
- };
50
- const key = 'row-' + idx;
51
- return (
52
-
53
- h('div', { key, className: 'csv-' + key, style: { display: 'flex', flexDirection: 'row', margin: 'auto' }}, [
54
- h('div', { className: 'csv-col-0', style: csvTableRowStyle },
55
- h(CsvToHtmlTable, { data: rowDataPair[0], csvDelimiter: ',', tableClassName: 'widget-csv-table' })
56
- ),
57
- h('div', { className: 'csv-col-1', style: csvTableRowStyle },
58
- rowDataPair[1]
59
- ? h(CsvToHtmlTable, { data: rowDataPair[1], csvDelimiter: ',', tableClassName: 'widget-csv-table' })
60
- : null,
61
- ),
62
- ])
63
- );
64
- });
65
-
66
- ReactDOM.render(
67
- h('div', { style: { display: 'flex', flexDirection: 'column' }}, rows),
68
- jupyterLabReactComponentContainer
69
- );
70
-
71
- function groupArrayIntoPairs(arr) {
72
- const pairs = [];
73
- for (let i = 0; i < arr.length; i += 2) {
74
- const pair = [arr[i], arr[i + 1]];
75
- pairs.push(pair);
76
- }
77
- return pairs;
78
- }
79
-
80
- </script>
81
- `;
82
- tslab.display.html(html);
83
- }
84
- exports.csv = csv;
85
- //# sourceMappingURL=csv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"csv.js","sourceRoot":"","sources":["../../src/csv/csv.ts"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAE/B,iDAA8C;AAE9C,yDAAyD;AACzD,SAAS,GAAG,CACX,IAAc,EACd,OAAoD;IAEpD,MAAM,gBAAgB,GAAG,cAAc,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;QAiBN,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,KAAI,EAAE;;eAEjB,gBAAgB;;2BAEJ,mBAAQ,CAAC,KAAK;8BACX,mBAAQ,CAAC,QAAQ;wCACP,mBAAQ,CAAC,eAAe;;;4CAGpB,gBAAgB;2EACe,gBAAgB;;sBAErE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;;;;;;;;;YAStD,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAC,CAAC,CAAC,aAAa,OAAO,CAAC,SAAS,sBAAsB,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCvF,CAAC;IACH,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAEQ,kBAAG"}
package/readme.md DELETED
@@ -1,77 +0,0 @@
1
- <center>
2
- <h2>⚙️📟📈 tslab-widgets 📈📟⚙️</h1>
3
- </center>
4
-
5
- <blockquote>
6
- A set of widgets for tslab (the interactive programming environment on top of jupyter lab that supports typescript and javascript).
7
- </blockquote>
8
- <hr />
9
- <br>
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
-
19
- ### Setup:
20
-
21
- - Install [tslab](https://github.com/yunabe/tslab)
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`
26
-
27
- ### Widget list:
28
-
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">
70
-
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">
72
-
73
- ### Author
74
-
75
- Rodrigo P.
76
-
77
- [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/rodrigopivi)