@icanbwell/baileyai-chat-ui 0.3.2 → 0.3.3
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/README.md +27 -0
- package/dist/baileyai-chat-ui.cjs +5 -5
- package/dist/baileyai-chat-ui.js +226 -228
- package/dist/chart.cjs +1 -0
- package/dist/chart.d.ts +36 -0
- package/dist/chart.js +67 -0
- package/dist/safeMarkdownUrl-DsMPGzpD.cjs +1 -0
- package/dist/safeMarkdownUrl-xI42YYzd.js +7 -0
- package/dist/table.cjs +1 -0
- package/dist/table.d.ts +20 -0
- package/dist/table.js +65 -0
- package/package.json +49 -2
package/dist/chart.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react/jsx-runtime"),n=require("@mui/material"),r=require("chart.js"),i=require("react-chartjs-2");r.Chart.register(r.CategoryScale,r.LinearScale,r.PointElement,r.LineElement,r.BarElement,r.ArcElement,r.Title,r.Tooltip,r.Legend,r.BarController,r.LineController,r.PieController,r.DoughnutController,r.ScatterController);var a=[`#2563eb`,`#16a34a`,`#7c3aed`,`#ea580c`,`#0d9488`,`#db2777`,`#4b5563`,`#ca8a04`],o=[`#60a5fa`,`#4ade80`,`#a78bfa`,`#fb923c`,`#2dd4bf`,`#f472b6`,`#d1d5db`,`#fbbf24`],s=({spec:r,isDarkMode:s=!1,palette:c})=>{let l=c??(s?o:a),u=r.type===`pie`||r.type===`doughnut`,d=(0,e.useMemo)(()=>({labels:r.data.labels,datasets:r.data.datasets.map((e,t)=>({label:e.label,data:e.data,backgroundColor:u?e.data.map((e,t)=>l[t%l.length]):l[t%l.length],borderColor:u?void 0:l[t%l.length]}))}),[r,u,l]),f=(0,e.useMemo)(()=>({responsive:!0,maintainAspectRatio:!1,plugins:{title:{display:!!r.title,text:r.title},legend:{display:r.data.datasets.length>1||u}}}),[r.title,r.data.datasets.length,u]);return(0,t.jsx)(n.Box,{sx:{my:1,height:300},children:(0,t.jsx)(i.Chart,{type:r.type,data:d,options:f})})};exports.BaileyChart=s,exports.DEFAULT_DARK_PALETTE=o,exports.DEFAULT_LIGHT_PALETTE=a;
|
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
|
|
3
|
+
export declare const BaileyChart: ({ spec, isDarkMode, palette }: BaileyChartProps) => JSX.Element;
|
|
4
|
+
|
|
5
|
+
declare interface BaileyChartDataset {
|
|
6
|
+
label: string;
|
|
7
|
+
data: number[] | Array<{
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare interface BaileyChartProps {
|
|
14
|
+
spec: BaileyChartSpec;
|
|
15
|
+
isDarkMode?: boolean;
|
|
16
|
+
/** Overrides the built-in default palette. Cycled by dataset index (or by pie/doughnut slice
|
|
17
|
+
* index for a sliced chart) the same way a host's own brand palette would be. */
|
|
18
|
+
palette?: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare interface BaileyChartSpec {
|
|
22
|
+
type: BaileyChartType;
|
|
23
|
+
title?: string;
|
|
24
|
+
data: {
|
|
25
|
+
labels?: string[];
|
|
26
|
+
datasets: BaileyChartDataset[];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare type BaileyChartType = 'bar' | 'line' | 'pie' | 'doughnut' | 'scatter';
|
|
31
|
+
|
|
32
|
+
export declare const DEFAULT_DARK_PALETTE: string[];
|
|
33
|
+
|
|
34
|
+
export declare const DEFAULT_LIGHT_PALETTE: string[];
|
|
35
|
+
|
|
36
|
+
export { }
|
package/dist/chart.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useMemo as e } from "react";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { Box as n } from "@mui/material";
|
|
4
|
+
import { ArcElement as r, BarController as i, BarElement as a, CategoryScale as o, Chart as s, DoughnutController as c, Legend as l, LineController as u, LineElement as d, LinearScale as f, PieController as p, PointElement as m, ScatterController as h, Title as g, Tooltip as _ } from "chart.js";
|
|
5
|
+
import { Chart as v } from "react-chartjs-2";
|
|
6
|
+
//#region src/ui/BaileyChart.tsx
|
|
7
|
+
s.register(o, f, m, d, a, r, g, _, l, i, u, p, c, h);
|
|
8
|
+
var y = [
|
|
9
|
+
"#2563eb",
|
|
10
|
+
"#16a34a",
|
|
11
|
+
"#7c3aed",
|
|
12
|
+
"#ea580c",
|
|
13
|
+
"#0d9488",
|
|
14
|
+
"#db2777",
|
|
15
|
+
"#4b5563",
|
|
16
|
+
"#ca8a04"
|
|
17
|
+
], b = [
|
|
18
|
+
"#60a5fa",
|
|
19
|
+
"#4ade80",
|
|
20
|
+
"#a78bfa",
|
|
21
|
+
"#fb923c",
|
|
22
|
+
"#2dd4bf",
|
|
23
|
+
"#f472b6",
|
|
24
|
+
"#d1d5db",
|
|
25
|
+
"#fbbf24"
|
|
26
|
+
], x = ({ spec: r, isDarkMode: i = !1, palette: a }) => {
|
|
27
|
+
let o = a ?? (i ? b : y), s = r.type === "pie" || r.type === "doughnut", c = e(() => ({
|
|
28
|
+
labels: r.data.labels,
|
|
29
|
+
datasets: r.data.datasets.map((e, t) => ({
|
|
30
|
+
label: e.label,
|
|
31
|
+
data: e.data,
|
|
32
|
+
backgroundColor: s ? e.data.map((e, t) => o[t % o.length]) : o[t % o.length],
|
|
33
|
+
borderColor: s ? void 0 : o[t % o.length]
|
|
34
|
+
}))
|
|
35
|
+
}), [
|
|
36
|
+
r,
|
|
37
|
+
s,
|
|
38
|
+
o
|
|
39
|
+
]), l = e(() => ({
|
|
40
|
+
responsive: !0,
|
|
41
|
+
maintainAspectRatio: !1,
|
|
42
|
+
plugins: {
|
|
43
|
+
title: {
|
|
44
|
+
display: !!r.title,
|
|
45
|
+
text: r.title
|
|
46
|
+
},
|
|
47
|
+
legend: { display: r.data.datasets.length > 1 || s }
|
|
48
|
+
}
|
|
49
|
+
}), [
|
|
50
|
+
r.title,
|
|
51
|
+
r.data.datasets.length,
|
|
52
|
+
s
|
|
53
|
+
]);
|
|
54
|
+
return /* @__PURE__ */ t(n, {
|
|
55
|
+
sx: {
|
|
56
|
+
my: 1,
|
|
57
|
+
height: 300
|
|
58
|
+
},
|
|
59
|
+
children: /* @__PURE__ */ t(v, {
|
|
60
|
+
type: r.type,
|
|
61
|
+
data: c,
|
|
62
|
+
options: l
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
//#endregion
|
|
67
|
+
export { x as BaileyChart, b as DEFAULT_DARK_PALETTE, y as DEFAULT_LIGHT_PALETTE };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=/^(https?|mailto):/i,t=e=>e.replace(/[\t\n\r]/g,``).trim(),n=n=>{let r=t(n);return!/^[a-z][a-z0-9+.-]*:/i.test(r)||e.test(r)};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
|
package/dist/table.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./safeMarkdownUrl-DsMPGzpD.cjs");let t=require("react"),n=require("react/jsx-runtime"),r=require("@mui/material"),i=require("ag-grid-react"),a=require("ag-grid-community");a.ModuleRegistry.registerModules([a.ColumnAutoSizeModule,a.ColumnHoverModule,a.RowAutoHeightModule,a.RowStyleModule,a.TooltipModule,a.TextFilterModule,a.NumberFilterModule,a.ClientSideRowModelModule]);var o={resizable:!0,sortable:!0,filter:!0},s=t=>{let i=t.colDef?.field?t.data?.[`${t.colDef.field}Href`]:void 0;return typeof i!=`string`||!e.t(i)?(0,n.jsx)(n.Fragment,{children:t.value}):(0,n.jsx)(r.Link,{href:i,target:`_blank`,rel:`noopener noreferrer`,children:t.value})},c=e=>e.trim()!==``&&Number.isFinite(Number(e)),l=({headers:e,rows:l,theme:u=a.themeBalham})=>{let{columnDefs:d,rowData:f}=(0,t.useMemo)(()=>{let t=e.map((e,t)=>l.some(e=>e[t]?.href)),n=e.map((e,n)=>{if(t[n])return!1;let r=l.map(e=>e[n]).filter(e=>!!e?.text.trim());return r.length>0&&r.every(e=>c(e.text))});return{columnDefs:e.map((e,r)=>({headerName:e,field:`col${r}`,...n[r]?{cellDataType:`number`}:{},...t[r]?{cellRenderer:s}:{}})),rowData:l.map(e=>e.reduce((e,t,r)=>{let i=`col${r}`,a=t.text.trim()===``;return e[i]=n[r]?a?null:Number(t.text):t.text,t.href&&(e[`${i}Href`]=t.href),e},{}))}},[e,l]);return(0,n.jsx)(r.Box,{sx:{width:`100%`,my:1},children:(0,n.jsx)(i.AgGridReact,{theme:u,columnDefs:d,rowData:f,defaultColDef:o,domLayout:`autoHeight`})})};exports.BaileyTable=l;
|
package/dist/table.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { Theme } from 'ag-grid-community';
|
|
3
|
+
|
|
4
|
+
export declare const BaileyTable: ({ headers, rows, theme }: BaileyTableProps) => JSX.Element;
|
|
5
|
+
|
|
6
|
+
declare interface BaileyTableCell {
|
|
7
|
+
text: string;
|
|
8
|
+
href?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export declare interface BaileyTableProps {
|
|
12
|
+
headers: string[];
|
|
13
|
+
rows: BaileyTableCell[][];
|
|
14
|
+
/** ag-grid Theming-API Theme object. Defaults to the stock themeBalham (no brand params) —
|
|
15
|
+
* a host with its own brand theme passes it here instead of this component reading any
|
|
16
|
+
* theme context of its own. */
|
|
17
|
+
theme?: Theme;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { }
|
package/dist/table.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { t as e } from "./safeMarkdownUrl-xI42YYzd.js";
|
|
2
|
+
import { useMemo as t } from "react";
|
|
3
|
+
import { Fragment as n, jsx as r } from "react/jsx-runtime";
|
|
4
|
+
import { Box as i, Link as a } from "@mui/material";
|
|
5
|
+
import { AgGridReact as o } from "ag-grid-react";
|
|
6
|
+
import { ClientSideRowModelModule as s, ColumnAutoSizeModule as c, ColumnHoverModule as l, ModuleRegistry as u, NumberFilterModule as d, RowAutoHeightModule as f, RowStyleModule as p, TextFilterModule as m, TooltipModule as h, themeBalham as g } from "ag-grid-community";
|
|
7
|
+
//#region src/ui/BaileyTable.tsx
|
|
8
|
+
u.registerModules([
|
|
9
|
+
c,
|
|
10
|
+
l,
|
|
11
|
+
f,
|
|
12
|
+
p,
|
|
13
|
+
h,
|
|
14
|
+
m,
|
|
15
|
+
d,
|
|
16
|
+
s
|
|
17
|
+
]);
|
|
18
|
+
var _ = {
|
|
19
|
+
resizable: !0,
|
|
20
|
+
sortable: !0,
|
|
21
|
+
filter: !0
|
|
22
|
+
}, v = (t) => {
|
|
23
|
+
let i = t.colDef?.field ? t.data?.[`${t.colDef.field}Href`] : void 0;
|
|
24
|
+
return typeof i != "string" || !e(i) ? /* @__PURE__ */ r(n, { children: t.value }) : /* @__PURE__ */ r(a, {
|
|
25
|
+
href: i,
|
|
26
|
+
target: "_blank",
|
|
27
|
+
rel: "noopener noreferrer",
|
|
28
|
+
children: t.value
|
|
29
|
+
});
|
|
30
|
+
}, y = (e) => e.trim() !== "" && Number.isFinite(Number(e)), b = ({ headers: e, rows: n, theme: a = g }) => {
|
|
31
|
+
let { columnDefs: s, rowData: c } = t(() => {
|
|
32
|
+
let t = e.map((e, t) => n.some((e) => e[t]?.href)), r = e.map((e, r) => {
|
|
33
|
+
if (t[r]) return !1;
|
|
34
|
+
let i = n.map((e) => e[r]).filter((e) => !!e?.text.trim());
|
|
35
|
+
return i.length > 0 && i.every((e) => y(e.text));
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
columnDefs: e.map((e, n) => ({
|
|
39
|
+
headerName: e,
|
|
40
|
+
field: `col${n}`,
|
|
41
|
+
...r[n] ? { cellDataType: "number" } : {},
|
|
42
|
+
...t[n] ? { cellRenderer: v } : {}
|
|
43
|
+
})),
|
|
44
|
+
rowData: n.map((e) => e.reduce((e, t, n) => {
|
|
45
|
+
let i = `col${n}`, a = t.text.trim() === "";
|
|
46
|
+
return e[i] = r[n] ? a ? null : Number(t.text) : t.text, t.href && (e[`${i}Href`] = t.href), e;
|
|
47
|
+
}, {}))
|
|
48
|
+
};
|
|
49
|
+
}, [e, n]);
|
|
50
|
+
return /* @__PURE__ */ r(i, {
|
|
51
|
+
sx: {
|
|
52
|
+
width: "100%",
|
|
53
|
+
my: 1
|
|
54
|
+
},
|
|
55
|
+
children: /* @__PURE__ */ r(o, {
|
|
56
|
+
theme: a,
|
|
57
|
+
columnDefs: s,
|
|
58
|
+
rowData: c,
|
|
59
|
+
defaultColDef: _,
|
|
60
|
+
domLayout: "autoHeight"
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { b as BaileyTable };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icanbwell/baileyai-chat-ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Shared React chat UI and streaming logic for Bailey, the icanbwell AI assistant",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,17 @@
|
|
|
24
24
|
"import": "./dist/baileyai-chat-ui.js",
|
|
25
25
|
"require": "./dist/baileyai-chat-ui.cjs"
|
|
26
26
|
},
|
|
27
|
-
"./styles.css": "./dist/baileyai-chat-ui.css"
|
|
27
|
+
"./styles.css": "./dist/baileyai-chat-ui.css",
|
|
28
|
+
"./table": {
|
|
29
|
+
"types": "./dist/table.d.ts",
|
|
30
|
+
"import": "./dist/table.js",
|
|
31
|
+
"require": "./dist/table.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./chart": {
|
|
34
|
+
"types": "./dist/chart.d.ts",
|
|
35
|
+
"import": "./dist/chart.js",
|
|
36
|
+
"require": "./dist/chart.cjs"
|
|
37
|
+
}
|
|
28
38
|
},
|
|
29
39
|
"files": [
|
|
30
40
|
"dist"
|
|
@@ -43,16 +53,49 @@
|
|
|
43
53
|
"lint": "eslint \"src/**/*.{ts,tsx}\" \"dev/**/*.{ts,tsx}\" \"vite.config.ts\" \"*.js\""
|
|
44
54
|
},
|
|
45
55
|
"peerDependencies": {
|
|
56
|
+
"@emotion/react": "^11.0.0",
|
|
57
|
+
"@emotion/styled": "^11.0.0",
|
|
58
|
+
"@mui/material": "^9.0.0",
|
|
59
|
+
"ag-grid-community": "^35.0.0",
|
|
60
|
+
"ag-grid-react": "^35.0.0",
|
|
61
|
+
"chart.js": "^4.0.0",
|
|
46
62
|
"react": "^19.0.0",
|
|
63
|
+
"react-chartjs-2": "^5.0.0",
|
|
47
64
|
"react-dom": "^19.0.0"
|
|
48
65
|
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"@emotion/react": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"@emotion/styled": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"@mui/material": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"ag-grid-community": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"ag-grid-react": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"chart.js": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"react-chartjs-2": {
|
|
86
|
+
"optional": true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
49
89
|
"dependencies": {
|
|
50
90
|
"@radix-ui/react-tooltip": "^1.1.8",
|
|
51
91
|
"react-markdown": "^10.1.0",
|
|
52
92
|
"remark-gfm": "^4.0.1"
|
|
53
93
|
},
|
|
54
94
|
"devDependencies": {
|
|
95
|
+
"@emotion/react": "^11.14.0",
|
|
96
|
+
"@emotion/styled": "^11.14.1",
|
|
55
97
|
"@eslint/js": "^9",
|
|
98
|
+
"@mui/material": "^9.0.1",
|
|
56
99
|
"@tailwindcss/postcss": "^4.3.3",
|
|
57
100
|
"@testing-library/dom": "^10.0.0",
|
|
58
101
|
"@testing-library/jest-dom": "^7.0.1",
|
|
@@ -61,13 +104,17 @@
|
|
|
61
104
|
"@types/react": "^19.2.17",
|
|
62
105
|
"@types/react-dom": "^19.2.3",
|
|
63
106
|
"@vitejs/plugin-react": "^4.3.4",
|
|
107
|
+
"ag-grid-community": "^35.3.0",
|
|
108
|
+
"ag-grid-react": "^35.3.0",
|
|
64
109
|
"autoprefixer": "^10.5.0",
|
|
110
|
+
"chart.js": "^4.5.1",
|
|
65
111
|
"eslint": "^9.39.1",
|
|
66
112
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
67
113
|
"eslint-plugin-react-refresh": "^0.5.4",
|
|
68
114
|
"jsdom": "^29.1.1",
|
|
69
115
|
"postcss": "^8.5.23",
|
|
70
116
|
"react": "^19.2.7",
|
|
117
|
+
"react-chartjs-2": "^5.3.1",
|
|
71
118
|
"react-dom": "^19.2.7",
|
|
72
119
|
"tailwindcss": "^4.3.1",
|
|
73
120
|
"typescript": "^6.0.3",
|