@visns-studio/visns-components 5.4.15 → 5.4.17
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/package.json
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-to-print": "^2.15.1",
|
|
50
50
|
"react-toastify": "^10.0.6",
|
|
51
51
|
"react-toggle": "^4.1.3",
|
|
52
|
-
"react-tooltip": "^5.28.
|
|
52
|
+
"react-tooltip": "^5.28.1",
|
|
53
53
|
"react-window": "^1.8.11",
|
|
54
54
|
"reactjs-popup": "^2.0.6",
|
|
55
55
|
"style-loader": "^4.0.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"truncate": "^3.0.0",
|
|
59
59
|
"uuid": "^10.0.0",
|
|
60
60
|
"validator": "^13.15.0",
|
|
61
|
-
"vite": "^5.4.
|
|
61
|
+
"vite": "^5.4.18",
|
|
62
62
|
"yarn": "^1.22.22"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
82
82
|
},
|
|
83
83
|
"name": "@visns-studio/visns-components",
|
|
84
|
-
"version": "5.4.
|
|
84
|
+
"version": "5.4.17",
|
|
85
85
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
86
86
|
"main": "src/index.js",
|
|
87
87
|
"files": [
|
|
@@ -37,6 +37,8 @@ function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
|
|
|
37
37
|
const [selectedAddWidgetId, setSelectedAddWidgetId] = useState('');
|
|
38
38
|
// Flag used only for triggering reinitialization after widget addition.
|
|
39
39
|
const [widgetAdded, setWidgetAdded] = useState(false);
|
|
40
|
+
// State to track viewport width
|
|
41
|
+
const [viewportWidth, setViewportWidth] = useState(window.innerWidth);
|
|
40
42
|
|
|
41
43
|
// Compute available widgets from original settings that are not yet added.
|
|
42
44
|
const availableWidgets = setting.widgets.filter(
|
|
@@ -188,6 +190,21 @@ function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
|
|
|
188
190
|
}
|
|
189
191
|
}, [dashboardSetting]);
|
|
190
192
|
|
|
193
|
+
// Handle window resize events to update viewportWidth
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
const handleResize = () => {
|
|
196
|
+
setViewportWidth(window.innerWidth);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Add event listener
|
|
200
|
+
window.addEventListener('resize', handleResize);
|
|
201
|
+
|
|
202
|
+
// Clean up event listener on component unmount
|
|
203
|
+
return () => {
|
|
204
|
+
window.removeEventListener('resize', handleResize);
|
|
205
|
+
};
|
|
206
|
+
}, []);
|
|
207
|
+
|
|
191
208
|
const openModal = (widgetId) => {
|
|
192
209
|
setModalContent(widgetId);
|
|
193
210
|
setModalShow(true);
|
|
@@ -867,8 +884,28 @@ function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
|
|
|
867
884
|
case 'table': {
|
|
868
885
|
const tableData = widgetData.data || widgetData;
|
|
869
886
|
const tableKeys = widgetData.keys || [];
|
|
887
|
+
|
|
888
|
+
// Calculate dynamic max-width based on viewport width
|
|
889
|
+
const getTableMaxWidth = () => {
|
|
890
|
+
// For very small screens (mobile)
|
|
891
|
+
if (viewportWidth < 768) {
|
|
892
|
+
return '100%';
|
|
893
|
+
}
|
|
894
|
+
// For medium screens (tablets)
|
|
895
|
+
else if (viewportWidth < 1200) {
|
|
896
|
+
return Math.min(viewportWidth * 0.9, 1000) + 'px';
|
|
897
|
+
}
|
|
898
|
+
// For large screens (desktops)
|
|
899
|
+
else {
|
|
900
|
+
return Math.min(viewportWidth * 0.9, 2560) + 'px';
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
|
|
870
904
|
return (
|
|
871
|
-
<div
|
|
905
|
+
<div
|
|
906
|
+
className={styles['table-container']}
|
|
907
|
+
style={{ maxWidth: getTableMaxWidth() }}
|
|
908
|
+
>
|
|
872
909
|
{tableData.length > 0 ? (
|
|
873
910
|
<div className={styles['table-scroll']}>
|
|
874
911
|
<table>
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# DataGrid Component
|
|
2
|
-
|
|
3
|
-
## Customizing Hover Color
|
|
4
|
-
|
|
5
|
-
The DataGrid component now supports customizable hover colors. This allows you to set different hover colors for different instances of the DataGrid.
|
|
6
|
-
|
|
7
|
-
### Method 1: Using the hoverColor Prop (Recommended)
|
|
8
|
-
|
|
9
|
-
The simplest way to set a custom hover color is to use the `hoverColor` prop directly:
|
|
10
|
-
|
|
11
|
-
```jsx
|
|
12
|
-
import DataGrid from './components/crm/DataGrid';
|
|
13
|
-
|
|
14
|
-
// In your component
|
|
15
|
-
<DataGrid
|
|
16
|
-
hoverColor="rgb(255, 240, 230)" // Custom hover color
|
|
17
|
-
// other props...
|
|
18
|
-
/>;
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Method 2: Using CSS Variables in Component Props
|
|
22
|
-
|
|
23
|
-
You can pass a custom style object to the DataGrid component with the `--hover-color` CSS variable:
|
|
24
|
-
|
|
25
|
-
```jsx
|
|
26
|
-
import DataGrid from './components/crm/DataGrid';
|
|
27
|
-
|
|
28
|
-
// Define custom styles with hover color
|
|
29
|
-
const customStyle = {
|
|
30
|
-
'--hover-color': 'rgb(255, 240, 230)', // Custom hover color
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// In your component
|
|
34
|
-
<DataGrid
|
|
35
|
-
style={customStyle}
|
|
36
|
-
// other props...
|
|
37
|
-
/>;
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Method 3: Using CSS/SCSS
|
|
41
|
-
|
|
42
|
-
You can define the `--hover-color` CSS variable in your CSS or SCSS files:
|
|
43
|
-
|
|
44
|
-
```css
|
|
45
|
-
/* Global default hover color */
|
|
46
|
-
:root {
|
|
47
|
-
--hover-color: rgb(230, 240, 250);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* For specific containers */
|
|
51
|
-
.special-grid-container {
|
|
52
|
-
--hover-color: rgb(255, 240, 230);
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Then apply the class to your container:
|
|
57
|
-
|
|
58
|
-
```jsx
|
|
59
|
-
<div className="special-grid-container">
|
|
60
|
-
<DataGrid {...props} />
|
|
61
|
-
</div>
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Default Value
|
|
65
|
-
|
|
66
|
-
If no hover color is specified (via prop or CSS variable), the DataGrid will use a default light blue color (`rgb(230, 240, 250)`).
|
|
67
|
-
|
|
68
|
-
### Example
|
|
69
|
-
|
|
70
|
-
See the `src/examples/CustomHoverDataGrid.jsx` file for a complete example of how to implement custom hover colors using all three methods.
|