@visns-studio/visns-components 5.13.15 → 5.13.16

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
@@ -88,7 +88,7 @@
88
88
  "react-dom": "^17.0.0 || ^18.0.0"
89
89
  },
90
90
  "name": "@visns-studio/visns-components",
91
- "version": "5.13.15",
91
+ "version": "5.13.16",
92
92
  "description": "Various packages to assist in the development of our Custom Applications.",
93
93
  "main": "src/index.js",
94
94
  "files": [
@@ -18,6 +18,62 @@ import styles from '../styles/GenericDashboard.module.scss';
18
18
 
19
19
  const toSnakeCase = (str) => str.replace(/[\s-]+/g, '_').toLowerCase();
20
20
 
21
+ const renderProgressBar = (value, options = {}) => {
22
+ const percentage = parseFloat(value) || 0;
23
+ const { showPercentage = true, color = 'primary' } = options;
24
+
25
+ const colorMap = {
26
+ primary: '#007bff',
27
+ success: '#28a745',
28
+ warning: '#ffc107',
29
+ danger: '#dc3545',
30
+ info: '#17a2b8'
31
+ };
32
+
33
+ const backgroundColor = colorMap[color] || colorMap.primary;
34
+
35
+ return (
36
+ <div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
37
+ <div
38
+ style={{
39
+ width: '100px',
40
+ height: '20px',
41
+ backgroundColor: '#e9ecef',
42
+ borderRadius: '10px',
43
+ overflow: 'hidden',
44
+ marginRight: showPercentage ? '8px' : '0'
45
+ }}
46
+ >
47
+ <div
48
+ style={{
49
+ width: `${Math.min(Math.max(percentage, 0), 100)}%`,
50
+ height: '100%',
51
+ backgroundColor: backgroundColor,
52
+ borderRadius: '10px',
53
+ transition: 'width 0.3s ease'
54
+ }}
55
+ />
56
+ </div>
57
+ {showPercentage && (
58
+ <span style={{ fontSize: '12px', color: '#6c757d', minWidth: '35px' }}>
59
+ {percentage.toFixed(1)}%
60
+ </span>
61
+ )}
62
+ </div>
63
+ );
64
+ };
65
+
66
+ const renderCellContent = (value, column, widget) => {
67
+ const columnFormatting = widget.columnFormatting || {};
68
+ const formatting = columnFormatting[column];
69
+
70
+ if (formatting && formatting.type === 'progressBar') {
71
+ return renderProgressBar(value, formatting);
72
+ }
73
+
74
+ return value;
75
+ };
76
+
21
77
  function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
22
78
  const swapy = useRef(null);
23
79
  const container = useRef(null);
@@ -1060,11 +1116,11 @@ function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
1060
1116
  <td
1061
1117
  key={`table-data-${rowIndex}-${columnIndex}`}
1062
1118
  >
1063
- {
1064
- row[
1065
- column
1066
- ]
1067
- }
1119
+ {renderCellContent(
1120
+ row[column],
1121
+ column,
1122
+ widget
1123
+ )}
1068
1124
  </td>
1069
1125
  )
1070
1126
  )}