blixify-ui-web-mcp 0.1.1 → 0.1.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/lib/components/chart/ganttChart/README.md +96 -110
- package/lib/components/chart/ganttChart/ganttChart.stories.tsx +132 -116
- package/lib/components/chart/heatmapChart/README.md +93 -82
- package/lib/components/chart/heatmapChart/heatmapChart.stories.tsx +118 -74
- package/lib/components/chat/chatAnchor/README.md +61 -79
- package/lib/components/chat/chatBase/README.md +166 -199
- package/lib/components/chat/chatBase/chatBase.stories.tsx +243 -265
- package/lib/components/chat/chatDashboard/README.md +87 -129
- package/lib/components/chat/chatDashboard/chatDashboard.stories.tsx +84 -107
- package/lib/components/data/dataGraph/README.md +135 -1
- package/lib/components/data/dataGraph/dataGraph.stories.tsx +86 -67
- package/lib/components/data/dataReference/README.md +141 -43
- package/lib/components/data/dataReference/dataReference.stories.tsx +107 -35
- package/lib/components/data/dataWrapper/README.md +2 -1
- package/lib/components/display/table/README.md +1 -1
- package/lib/components/navigation/bars/README.md +90 -17
- package/lib/components/navigation/bars/bars.stories.tsx +125 -51
- package/lib/components/navigation/breadcrumb/README.md +40 -20
- package/lib/components/navigation/breadcrumb/breadcrumb.stories.tsx +30 -4
- package/lib/components/navigation/header/README.md +67 -108
- package/lib/components/navigation/header/header.stories.tsx +143 -39
- package/lib/components/navigation/leftNav/README.md +121 -66
- package/lib/components/navigation/leftNav/leftNav.stories.tsx +176 -83
- package/lib/components/navigation/tabs/tabs.stories.tsx +53 -29
- package/lib/mcp/server.d.ts +1 -0
- package/lib/mcp/server.js +1 -0
- package/lib/mcp/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,53 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
<hr>
|
|
6
6
|
|
|
7
|
-
A heatmap chart
|
|
7
|
+
A heatmap chart for visualising data density across two dimensions. Each cell is colour-coded by value using a built-in four-range scale (Low → Medium → High → Very High). Supports multi-series data, dark mode, date range filtering, and a clickable title link.
|
|
8
8
|
|
|
9
9
|
##### Import
|
|
10
10
|
|
|
11
11
|
```js
|
|
12
|
-
import { HeatmapChart } from "blixify-ui-web/
|
|
12
|
+
import { HeatmapChart } from "blixify-ui-web/components/chart/heatmapChart";
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
##### Usage
|
|
16
16
|
|
|
17
|
+
Basic multi-series heatmap:
|
|
18
|
+
|
|
17
19
|
```jsx
|
|
18
20
|
const multiSeriesData = [
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160,
|
|
23
|
-
170, 180,
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: "Metric2",
|
|
28
|
-
data: [
|
|
29
|
-
15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165,
|
|
30
|
-
175, 185,
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: "Metric3",
|
|
35
|
-
data: [
|
|
36
|
-
20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170,
|
|
37
|
-
180, 190,
|
|
38
|
-
],
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: "Metric4",
|
|
42
|
-
data: [
|
|
43
|
-
25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175,
|
|
44
|
-
185, 195,
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: "Metric5",
|
|
49
|
-
data: [
|
|
50
|
-
30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180,
|
|
51
|
-
190, 200,
|
|
52
|
-
],
|
|
53
|
-
},
|
|
21
|
+
{ name: "Week 1", data: [10, 45, 80, 120, 5, 60, 30, 95, 15, 70, 40, 110] },
|
|
22
|
+
{ name: "Week 2", data: [20, 55, 90, 10, 75, 35, 100, 25, 85, 50, 130, 65] },
|
|
23
|
+
{ name: "Week 3", data: [5, 30, 60, 95, 40, 115, 20, 80, 45, 105, 15, 70] },
|
|
54
24
|
];
|
|
55
25
|
|
|
56
26
|
const categories = [
|
|
@@ -66,39 +36,51 @@ const categories = [
|
|
|
66
36
|
"Oct",
|
|
67
37
|
"Nov",
|
|
68
38
|
"Dec",
|
|
69
|
-
"Q1",
|
|
70
|
-
"Q2",
|
|
71
|
-
"Q3",
|
|
72
|
-
"Q4",
|
|
73
|
-
"Y1",
|
|
74
|
-
"Y2",
|
|
75
39
|
];
|
|
76
40
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
41
|
+
<HeatmapChart
|
|
42
|
+
title="Monthly Activity"
|
|
43
|
+
multiSeriesData={multiSeriesData}
|
|
44
|
+
categories={categories}
|
|
45
|
+
showDataLabel={true}
|
|
46
|
+
/>;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
With date range picker and toolbar:
|
|
50
|
+
|
|
51
|
+
```jsx
|
|
52
|
+
<HeatmapChart
|
|
53
|
+
title="Activity Distribution"
|
|
54
|
+
multiSeriesData={multiSeriesData}
|
|
55
|
+
categories={categories}
|
|
56
|
+
showToolbar={true}
|
|
57
|
+
dateRangeVisible={true}
|
|
58
|
+
onChangeDate={(range) => console.log(range)}
|
|
59
|
+
/>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Dark mode:
|
|
63
|
+
|
|
64
|
+
```jsx
|
|
65
|
+
<HeatmapChart
|
|
66
|
+
title="Activity Distribution"
|
|
67
|
+
multiSeriesData={multiSeriesData}
|
|
68
|
+
categories={categories}
|
|
69
|
+
darkMode={true}
|
|
70
|
+
darkModeBg="bg-gray-900"
|
|
71
|
+
/>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Chart only (no card wrapper):
|
|
75
|
+
|
|
76
|
+
```jsx
|
|
77
|
+
<HeatmapChart
|
|
78
|
+
title="Minimal"
|
|
79
|
+
multiSeriesData={multiSeriesData}
|
|
80
|
+
categories={categories}
|
|
81
|
+
chartOnly={true}
|
|
82
|
+
containerStyle="h-64 w-full"
|
|
83
|
+
/>
|
|
102
84
|
```
|
|
103
85
|
|
|
104
86
|
##### Required props
|
|
@@ -109,17 +91,46 @@ return (
|
|
|
109
91
|
|
|
110
92
|
##### Optional props
|
|
111
93
|
|
|
112
|
-
| Name
|
|
113
|
-
|
|
|
114
|
-
| `multiSeriesData`
|
|
115
|
-
| `categories`
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
94
|
+
| Name | Type | Default | Description |
|
|
95
|
+
| ------------------ | ---------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------ |
|
|
96
|
+
| `multiSeriesData` | `SeriesItem[]` | — | Array of series — each becomes a row in the heatmap. See SeriesItem below. |
|
|
97
|
+
| `categories` | `string[] \| number[]` | — | X-axis category labels. Length should match the `data` array length in each series. |
|
|
98
|
+
| `showDataLabel` | `boolean` | `true` | Show or hide the numeric value label inside each cell |
|
|
99
|
+
| `showToolbar` | `boolean` | — | Show or hide the ApexCharts toolbar (download, zoom, etc.) |
|
|
100
|
+
| `borderColor` | `string` | `#e7e7e7` | Grid border color |
|
|
101
|
+
| `newTabUrl` | `string` | — | When set, wraps the chart title in a link to this URL |
|
|
102
|
+
| `onClick` | `(x: string, y: string, value: number) => void` | — | Called when a cell is clicked with its x category, y series name, and numeric value |
|
|
103
|
+
| `colors` | `string[]` | — | Custom color array. Falls back to `localStorage.localChartColors` then the built-in color scale. |
|
|
104
|
+
| `enableGradient` | `boolean` | `false` | Applies a gradient fill to cells |
|
|
105
|
+
| `darkMode` | `boolean` | `false` | Switches axis labels and text to white |
|
|
106
|
+
| `darkModeBg` | `string` | `bg-gray-900` | Tailwind bg class for the card background in dark mode |
|
|
107
|
+
| `dateRangeVisible` | `boolean` | `false` | Shows a date range picker below the chart |
|
|
108
|
+
| `customDate` | `RangeInterface` | — | Pre-selected date range passed to the date range picker |
|
|
109
|
+
| `onChangeDate` | `(date?: RangeInterface) => void` | — | Called when the date range picker value changes |
|
|
110
|
+
| `chartSize` | `number` | `280` | Chart height in pixels |
|
|
111
|
+
| `chartOnly` | `boolean` | `false` | Renders only the chart with no card wrapper. Use `containerStyle` to size the container. |
|
|
112
|
+
| `containerStyle` | `string` | — | Tailwind classes applied to the outer container |
|
|
113
|
+
| `tool` | `ReactElement` | — | Extra element rendered in the top-right of the chart header |
|
|
114
|
+
| `minInterval` | `number` | — | Minimum interval for the date range picker |
|
|
115
|
+
| `linkType` | `"react" \| "gatsby" \| "next" \| "external" \| "default"` | — | Router adapter used when `newTabUrl` is set |
|
|
116
|
+
| `custom` | `any` | — | Custom link component used when `linkType` is `"react"`, `"gatsby"`, or `"next"` |
|
|
117
|
+
|
|
118
|
+
##### Built-in colour scale
|
|
119
|
+
|
|
120
|
+
The heatmap uses a fixed four-range colour scale by default:
|
|
121
|
+
|
|
122
|
+
| Range | Colour | Label |
|
|
123
|
+
| --------- | --------- | --------- |
|
|
124
|
+
| 0 – 10 | `#00A100` | Low |
|
|
125
|
+
| 11 – 50 | `#128FD9` | Medium |
|
|
126
|
+
| 51 – 100 | `#FFB200` | High |
|
|
127
|
+
| 101 – 200 | `#FF4560` | Very High |
|
|
128
|
+
|
|
129
|
+
Pass `colors` to override this scale with ApexCharts' default colour assignment.
|
|
130
|
+
|
|
131
|
+
##### SeriesItem
|
|
132
|
+
|
|
133
|
+
| Name | Type | Description |
|
|
134
|
+
| ------ | ---------- | ---------------------------------------------------------- |
|
|
135
|
+
| `name` | `string` | Row label shown on the y-axis |
|
|
136
|
+
| `data` | `number[]` | Numeric values for each x-axis category, in the same order |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PencilIcon } from "@heroicons/react/24/outline";
|
|
2
1
|
import { storiesOf } from "@storybook/react";
|
|
3
2
|
import React, { useMemo } from "react";
|
|
4
3
|
import { HeatmapChart } from ".";
|
|
4
|
+
import { StorySection } from "../../storyUtils";
|
|
5
5
|
import README from "./README.md";
|
|
6
6
|
|
|
7
7
|
const stories = storiesOf("Chart", module);
|
|
@@ -12,95 +12,139 @@ stories.addParameters({
|
|
|
12
12
|
},
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
const categories = [
|
|
16
|
+
"Jan",
|
|
17
|
+
"Feb",
|
|
18
|
+
"Mar",
|
|
19
|
+
"Apr",
|
|
20
|
+
"May",
|
|
21
|
+
"Jun",
|
|
22
|
+
"Jul",
|
|
23
|
+
"Aug",
|
|
24
|
+
"Sep",
|
|
25
|
+
"Oct",
|
|
26
|
+
"Nov",
|
|
27
|
+
"Dec",
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const rand = (min: number, max: number) =>
|
|
31
|
+
Math.floor(Math.random() * (max - min + 1)) + min;
|
|
28
32
|
|
|
29
33
|
stories.add("Heatmap Chart", () => {
|
|
30
|
-
// Multi-series data example
|
|
31
34
|
const multiSeriesData = useMemo(
|
|
32
35
|
() => [
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: "Metric2",
|
|
39
|
-
data: generateData(18, { min: 0, max: 90 }),
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "Metric3",
|
|
43
|
-
data: generateData(18, { min: 0, max: 90 }),
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: "Metric4",
|
|
47
|
-
data: generateData(18, { min: 0, max: 90 }),
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: "Metric5",
|
|
51
|
-
data: generateData(18, { min: 0, max: 90 }),
|
|
52
|
-
},
|
|
36
|
+
{ name: "Week 1", data: categories.map(() => rand(0, 90)) },
|
|
37
|
+
{ name: "Week 2", data: categories.map(() => rand(0, 90)) },
|
|
38
|
+
{ name: "Week 3", data: categories.map(() => rand(0, 90)) },
|
|
39
|
+
{ name: "Week 4", data: categories.map(() => rand(0, 90)) },
|
|
40
|
+
{ name: "Week 5", data: categories.map(() => rand(0, 90)) },
|
|
53
41
|
],
|
|
54
42
|
[]
|
|
55
43
|
);
|
|
56
44
|
|
|
57
|
-
const
|
|
45
|
+
const wideSeriesData = useMemo(
|
|
58
46
|
() => [
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"Apr",
|
|
63
|
-
"May",
|
|
64
|
-
"Jun",
|
|
65
|
-
"Jul",
|
|
66
|
-
"Aug",
|
|
67
|
-
"Sep",
|
|
68
|
-
"Oct",
|
|
69
|
-
"Nov",
|
|
70
|
-
"Dec",
|
|
71
|
-
"Q1",
|
|
72
|
-
"Q2",
|
|
73
|
-
"Q3",
|
|
74
|
-
"Q4",
|
|
75
|
-
"Y1",
|
|
76
|
-
"Y2",
|
|
47
|
+
{ name: "Metric A", data: categories.map(() => rand(0, 200)) },
|
|
48
|
+
{ name: "Metric B", data: categories.map(() => rand(0, 200)) },
|
|
49
|
+
{ name: "Metric C", data: categories.map(() => rand(0, 200)) },
|
|
77
50
|
],
|
|
78
51
|
[]
|
|
79
52
|
);
|
|
80
53
|
|
|
81
54
|
return (
|
|
82
55
|
<>
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
56
|
+
<StorySection
|
|
57
|
+
title="Default"
|
|
58
|
+
description="Each SeriesItem becomes a row. Values are colour-coded by the built-in scale: green (0–10), blue (11–50), amber (51–100), red (101–200). showDataLabel shows the numeric value inside each cell."
|
|
59
|
+
>
|
|
60
|
+
<div className="w-full">
|
|
61
|
+
<HeatmapChart
|
|
62
|
+
title="Monthly Activity"
|
|
63
|
+
multiSeriesData={multiSeriesData}
|
|
64
|
+
categories={categories}
|
|
65
|
+
showDataLabel={true}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
</StorySection>
|
|
69
|
+
|
|
70
|
+
<StorySection
|
|
71
|
+
title="Full Colour Scale"
|
|
72
|
+
description="Values spanning all four ranges (0–200) show the complete built-in colour scale in one chart."
|
|
73
|
+
>
|
|
74
|
+
<div className="w-full">
|
|
75
|
+
<HeatmapChart
|
|
76
|
+
title="Full Range Metrics"
|
|
77
|
+
multiSeriesData={wideSeriesData}
|
|
78
|
+
categories={categories}
|
|
79
|
+
showDataLabel={true}
|
|
80
|
+
showToolbar={true}
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
</StorySection>
|
|
84
|
+
|
|
85
|
+
<StorySection
|
|
86
|
+
title="With Date Range Picker"
|
|
87
|
+
description="dateRangeVisible=true shows a date range picker below the chart. onChangeDate is called when the range changes."
|
|
88
|
+
>
|
|
89
|
+
<div className="w-full">
|
|
90
|
+
<HeatmapChart
|
|
91
|
+
title="Activity Over Time"
|
|
92
|
+
multiSeriesData={multiSeriesData}
|
|
93
|
+
categories={categories}
|
|
94
|
+
showDataLabel={false}
|
|
95
|
+
dateRangeVisible={true}
|
|
96
|
+
onChangeDate={(range) => console.log("Date range changed", range)}
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
</StorySection>
|
|
100
|
+
|
|
101
|
+
<StorySection
|
|
102
|
+
title="Clickable Title Link"
|
|
103
|
+
description="newTabUrl wraps the chart title in a link. Useful for navigating to a detail page from a dashboard."
|
|
104
|
+
>
|
|
105
|
+
<div className="w-full">
|
|
106
|
+
<HeatmapChart
|
|
107
|
+
title="Activity (click title)"
|
|
108
|
+
multiSeriesData={multiSeriesData}
|
|
109
|
+
categories={categories}
|
|
110
|
+
showDataLabel={true}
|
|
111
|
+
newTabUrl="https://www.google.com/"
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
</StorySection>
|
|
115
|
+
|
|
116
|
+
<StorySection
|
|
117
|
+
title="Dark Mode"
|
|
118
|
+
description="darkMode=true switches axis labels and text to white. darkModeBg sets the card background colour."
|
|
119
|
+
dark
|
|
120
|
+
>
|
|
121
|
+
<div className="w-full">
|
|
122
|
+
<HeatmapChart
|
|
123
|
+
title="Activity Distribution"
|
|
124
|
+
multiSeriesData={multiSeriesData}
|
|
125
|
+
categories={categories}
|
|
126
|
+
showDataLabel={true}
|
|
127
|
+
darkMode={true}
|
|
128
|
+
darkModeBg="bg-gray-900"
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
</StorySection>
|
|
92
132
|
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
133
|
+
<StorySection
|
|
134
|
+
title="Chart Only"
|
|
135
|
+
description="chartOnly=true strips the card wrapper and renders just the chart. Use containerStyle to control dimensions."
|
|
136
|
+
>
|
|
137
|
+
<div className="w-full h-64">
|
|
138
|
+
<HeatmapChart
|
|
139
|
+
title="Minimal"
|
|
140
|
+
multiSeriesData={multiSeriesData}
|
|
141
|
+
categories={categories}
|
|
142
|
+
chartOnly={true}
|
|
143
|
+
containerStyle="h-64 w-full"
|
|
144
|
+
showDataLabel={false}
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
147
|
+
</StorySection>
|
|
104
148
|
</>
|
|
105
149
|
);
|
|
106
150
|
});
|
|
@@ -4,110 +4,92 @@
|
|
|
4
4
|
|
|
5
5
|
<hr>
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
A floating chat button fixed to the viewport. Clicking it toggles the `ChatBase` panel open/closed with an animated transition. On mobile (< 640px) the chat panel expands to full screen when open.
|
|
8
8
|
|
|
9
9
|
##### Import
|
|
10
10
|
|
|
11
11
|
```js
|
|
12
12
|
import { ChatAnchor } from "blixify-ui-web/components/chat/chatAnchor";
|
|
13
|
-
import {
|
|
14
|
-
ChatBase,
|
|
15
|
-
Conversation,
|
|
16
|
-
} from "blixify-ui-web/components/chat/chatBase";
|
|
13
|
+
import { Conversation } from "blixify-ui-web/components/chat/chatBase";
|
|
17
14
|
```
|
|
18
15
|
|
|
19
16
|
##### Usage
|
|
20
17
|
|
|
21
18
|
```tsx
|
|
22
|
-
const [
|
|
19
|
+
const [open, setOpen] = useState(false);
|
|
23
20
|
const [message, setMessage] = useState("");
|
|
24
|
-
const [search, setSearch] = useState("");
|
|
25
|
-
const [filteredConversation, setFilteredConversation] =
|
|
26
|
-
useState<Conversation | null>();
|
|
27
21
|
const [conversation, setConversation] = useState<Conversation>({
|
|
28
22
|
id: "1",
|
|
29
23
|
members: [currentUser, botUser],
|
|
30
|
-
messageList: [
|
|
31
|
-
{
|
|
32
|
-
sender: botUser,
|
|
33
|
-
messageBody: "Hi! How can I help you? 🤖",
|
|
34
|
-
createdAt: moment(
|
|
35
|
-
"Fri Nov 03 2023 12:21:14 GMT+0800 (Malaysia Time)"
|
|
36
|
-
).toDate(),
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
sender: currentUser,
|
|
40
|
-
messageBody: "Yo, my computer's acting up.",
|
|
41
|
-
createdAt: moment(
|
|
42
|
-
"Fri Nov 03 2023 13:21:14 GMT+0800 (Malaysia Time)"
|
|
43
|
-
).toDate(),
|
|
44
|
-
},
|
|
45
|
-
],
|
|
24
|
+
messageList: [],
|
|
46
25
|
});
|
|
47
26
|
|
|
48
|
-
const handleOnClick = () => setOpenChatBase(!openChatBase);
|
|
49
|
-
|
|
50
|
-
const handleOnSendMessage = (conversation: Conversation) => {
|
|
51
|
-
setConversation(conversation);
|
|
52
|
-
setMessage("");
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const handleOnSearch = (searchMessage: string) => {
|
|
56
|
-
if (searchMessage.length === 0) {
|
|
57
|
-
setSearch("");
|
|
58
|
-
setFilteredConversation(null);
|
|
59
|
-
} else {
|
|
60
|
-
const dupMessageList = conversation.messageList.filter((eachMessage) => {
|
|
61
|
-
return eachMessage.messageBody
|
|
62
|
-
.toLowerCase()
|
|
63
|
-
.includes(searchMessage.toLowerCase());
|
|
64
|
-
});
|
|
65
|
-
const dupConversation = {
|
|
66
|
-
id: conversation.id,
|
|
67
|
-
members: [...conversation.members],
|
|
68
|
-
messageList: [...dupMessageList],
|
|
69
|
-
};
|
|
70
|
-
setFilteredConversation(dupConversation);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const headerElement = (
|
|
75
|
-
<div className="p-2 bg-primary-500 rounded-t-md">
|
|
76
|
-
<img src={Logo} alt="" className="h-12" />
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
|
|
80
27
|
return (
|
|
81
28
|
<ChatAnchor
|
|
82
|
-
open={
|
|
29
|
+
open={open}
|
|
83
30
|
value={message}
|
|
84
31
|
currentUser={currentUser}
|
|
85
|
-
conversation={
|
|
86
|
-
headerElement={
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
32
|
+
conversation={conversation}
|
|
33
|
+
headerElement={
|
|
34
|
+
<div className="p-2 bg-primary-500">
|
|
35
|
+
<img src={Logo} className="h-12" />
|
|
36
|
+
</div>
|
|
37
|
+
}
|
|
38
|
+
onSendMessage={(c) => {
|
|
39
|
+
setConversation(c);
|
|
40
|
+
setMessage("");
|
|
41
|
+
}}
|
|
90
42
|
onChangeMessage={(e) => setMessage(e.target.value)}
|
|
91
|
-
|
|
92
|
-
|
|
43
|
+
onClose={() => setOpen(false)}
|
|
44
|
+
onClick={() => setOpen(!open)}
|
|
93
45
|
className="shadow-lg border border-gray-200"
|
|
94
|
-
|
|
46
|
+
greetingCard
|
|
47
|
+
greetingText="Ask me anything!"
|
|
95
48
|
/>
|
|
96
49
|
);
|
|
97
50
|
```
|
|
98
51
|
|
|
99
52
|
##### Required props
|
|
100
53
|
|
|
101
|
-
| Name
|
|
102
|
-
|
|
|
103
|
-
| onClick
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
| `
|
|
54
|
+
| Name | Type | Description |
|
|
55
|
+
| -------------- | -------------- | ------------------------------------------------------ |
|
|
56
|
+
| `onClick` | `() => void` | Called when the floating anchor button is clicked |
|
|
57
|
+
| `open` | `boolean` | Controls whether the chat panel is visible |
|
|
58
|
+
| `value` | `string` | Current value of the message input |
|
|
59
|
+
| `currentUser` | `User` | The logged-in user (`{ id, name, imageUrl? }`) |
|
|
60
|
+
| `conversation` | `Conversation` | Conversation object containing members and messageList |
|
|
61
|
+
|
|
62
|
+
##### Optional props — ChatAnchor specific
|
|
63
|
+
|
|
64
|
+
| Name | Type | Default | Description |
|
|
65
|
+
| ---------------- | ----------------------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `positionOffset` | `string` | `"bottom-8 right-8"` | Tailwind classes that control the fixed position of the anchor. Ignored on mobile when open. |
|
|
67
|
+
| `greetingCard` | `boolean` | `false` | When `true`, shows a greeting bubble next to the anchor button while the chat is closed. |
|
|
68
|
+
| `greetingText` | `string` | `"Welcome! How can I help you today?"` | Text displayed inside the greeting card bubble. |
|
|
69
|
+
| `openIcon` | `React.ReactNode` \| `string` | `ChatBubbleOvalLeftIcon` | Icon shown when the chat is closed. A string is treated as an image URL (64×64 rounded circle). |
|
|
70
|
+
| `closeIcon` | `React.ReactNode` \| `string` | `XMarkIcon` | Icon shown when the chat is open. A string is treated as an image URL (64×64 rounded circle). |
|
|
71
|
+
|
|
72
|
+
##### Optional props — inherited from ChatBase
|
|
73
|
+
|
|
74
|
+
| Name | Type | Description |
|
|
75
|
+
| ---------------------- | -------------------------------------- | ------------------------------------------------------------------------------ |
|
|
76
|
+
| `headerElement` | `ReactElement` | Custom header rendered at the top of the chat panel |
|
|
77
|
+
| `bodyElement` | `ReactElement` | Replaces the default message list with a custom element |
|
|
78
|
+
| `footerElement` | `ReactElement` | Rendered below the message list, above the input bar |
|
|
79
|
+
| `additionalAction` | `ChatBaseAction[]` | Extra items added to the actions dropdown menu |
|
|
80
|
+
| `hideAdditionalAction` | `boolean` | Hides the actions dropdown entirely |
|
|
81
|
+
| `disableMessageInput` | `boolean` | Disables the text input |
|
|
82
|
+
| `isLoadingReply` | `boolean` | Shows a typing indicator and disables input while waiting for a reply |
|
|
83
|
+
| `className` | `string` | Extra classes applied to the chat panel container |
|
|
84
|
+
| `sizeClassName` | `string` | Overrides the default panel size (`h-[75vh] w-96` on desktop) |
|
|
85
|
+
| `disableMobileResize` | `boolean` | Prevents the panel from going full screen on mobile |
|
|
86
|
+
| `paddingTop` | `number` | Top padding (px) applied to the chat panel — useful when a sticky bar overlaps |
|
|
87
|
+
| `searchMessage` | `string` | Current search query value |
|
|
88
|
+
| `onSendMessage` | `(conversation: Conversation) => void` | Called with the updated conversation when a message is sent |
|
|
89
|
+
| `onChangeMessage` | `(event: any) => void` | Called on every keystroke in the message input |
|
|
90
|
+
| `onSearch` | `(searchMessage: string) => void` | Called when the search is submitted |
|
|
91
|
+
| `onChangeSearch` | `(event: any) => void` | Called on every keystroke in the search input |
|
|
92
|
+
| `onClose` | `() => void` | Called when the mobile close button is tapped |
|
|
93
|
+
| `onHiddenChatText` | `boolean` | Hides the text input and file clip icon entirely |
|
|
94
|
+
| `fileUpload` | `FileUpload` | Configuration object for file upload support |
|
|
95
|
+
| `lib` | `{ axios?: any }` | Additional libraries (e.g. axios for file uploads) |
|