@visns-studio/visns-components 5.4.14 → 5.4.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
@@ -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.0",
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.17",
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.14",
84
+ "version": "5.4.16",
85
85
  "description": "Various packages to assist in the development of our Custom Applications.",
86
86
  "main": "src/index.js",
87
87
  "files": [
@@ -15,6 +15,44 @@ function Breadcrumb({ data, page }) {
15
15
  : data[keys];
16
16
  };
17
17
 
18
+ // Function to evaluate condition for displaying image
19
+ const evaluateCondition = (condition) => {
20
+ if (!condition || !Array.isArray(condition) || condition.length === 0) {
21
+ return false;
22
+ }
23
+
24
+ return condition.every((cond) => {
25
+ if (!cond.id || !cond.value || !cond.operator || !data[cond.id]) {
26
+ return false;
27
+ }
28
+
29
+ const fieldValue = data[cond.id];
30
+ const condValue = cond.value;
31
+
32
+ switch (cond.operator) {
33
+ case 'eq': // equals
34
+ return fieldValue === condValue;
35
+ case 'neq': // not equals
36
+ return fieldValue !== condValue;
37
+ case 'gt': // greater than
38
+ return parseFloat(fieldValue) > parseFloat(condValue);
39
+ case 'gte': // greater than or equal
40
+ return parseFloat(fieldValue) >= parseFloat(condValue);
41
+ case 'lt': // less than
42
+ return parseFloat(fieldValue) < parseFloat(condValue);
43
+ case 'lte': // less than or equal
44
+ return parseFloat(fieldValue) <= parseFloat(condValue);
45
+ default:
46
+ return false;
47
+ }
48
+ });
49
+ };
50
+
51
+ // Check if image should be displayed based on condition
52
+ const shouldDisplayImage = page?.image?.condition
53
+ ? evaluateCondition(page.image.condition)
54
+ : false;
55
+
18
56
  // Get the nested data for parent title key if it exists
19
57
  const nestedData =
20
58
  data && page.parentTitleKey
@@ -102,6 +140,21 @@ function Breadcrumb({ data, page }) {
102
140
  )}
103
141
  </>
104
142
  )}
143
+
144
+ {/* Display image if condition is met */}
145
+ {shouldDisplayImage && page?.image?.url && (
146
+ <img
147
+ src={page.image.url}
148
+ alt="Verification Badge"
149
+ style={{
150
+ marginLeft: '12px',
151
+ height: '30px',
152
+ width: 'auto',
153
+ verticalAlign: 'middle',
154
+ filter: 'drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2))',
155
+ }}
156
+ />
157
+ )}
105
158
  </h1>
106
159
  );
107
160
  }
@@ -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 className={styles['table-container']}>
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>
@@ -387,7 +387,7 @@
387
387
  border: 1px solid #dadce0;
388
388
  border-radius: 8px;
389
389
  overflow: hidden;
390
- max-width: 1400px;
390
+ width: 100%;
391
391
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
392
392
  }
393
393