@visns-studio/visns-components 5.11.17 → 5.11.19
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
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
88
88
|
},
|
|
89
89
|
"name": "@visns-studio/visns-components",
|
|
90
|
-
"version": "5.11.
|
|
90
|
+
"version": "5.11.19",
|
|
91
91
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
92
92
|
"main": "src/index.js",
|
|
93
93
|
"files": [
|
|
@@ -294,15 +294,38 @@ const DataGrid = ({
|
|
|
294
294
|
|
|
295
295
|
const onRowClick = useCallback(
|
|
296
296
|
(rowProps, event) => {
|
|
297
|
+
// Safely get cell element and column index
|
|
297
298
|
const cellElement = event.target.closest(
|
|
298
299
|
'.InovuaReactDataGrid__cell'
|
|
299
300
|
);
|
|
301
|
+
|
|
302
|
+
// Return early if we can't find the cell element
|
|
303
|
+
if (!cellElement || !cellElement.parentNode) {
|
|
304
|
+
// Fallback: open edit modal if available
|
|
305
|
+
const updateSetting = settings.find(setting => setting.id === 'update');
|
|
306
|
+
if (updateSetting && form.primaryKey && rowProps.data[form.primaryKey]) {
|
|
307
|
+
modalOpen('update', rowProps.data[form.primaryKey]);
|
|
308
|
+
}
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
300
312
|
const columnIndex = Array.from(
|
|
301
313
|
cellElement.parentNode.children
|
|
302
314
|
).indexOf(cellElement);
|
|
303
315
|
|
|
316
|
+
// Return early if column index is invalid
|
|
317
|
+
if (columnIndex === -1 || !rowProps.columns[columnIndex]) {
|
|
318
|
+
// Fallback: open edit modal if available
|
|
319
|
+
const updateSetting = settings.find(setting => setting.id === 'update');
|
|
320
|
+
if (updateSetting && form.primaryKey && rowProps.data[form.primaryKey]) {
|
|
321
|
+
modalOpen('update', rowProps.data[form.primaryKey]);
|
|
322
|
+
}
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
304
326
|
let proceed = true;
|
|
305
327
|
|
|
328
|
+
// Check if clicked column is a toggle type
|
|
306
329
|
columns.forEach((a, b) => {
|
|
307
330
|
if (
|
|
308
331
|
a.id === rowProps.columns[columnIndex].id &&
|
|
@@ -313,6 +336,7 @@ const DataGrid = ({
|
|
|
313
336
|
});
|
|
314
337
|
|
|
315
338
|
if (proceed) {
|
|
339
|
+
// Check if column has navigation link
|
|
316
340
|
if (
|
|
317
341
|
rowProps.columns[columnIndex].link &&
|
|
318
342
|
rowProps.columns[columnIndex].link.url
|
|
@@ -339,10 +363,16 @@ const DataGrid = ({
|
|
|
339
363
|
}
|
|
340
364
|
);
|
|
341
365
|
}
|
|
366
|
+
} else {
|
|
367
|
+
// Fallback: open edit modal if no navigation link is configured
|
|
368
|
+
const updateSetting = settings.find(setting => setting.id === 'update');
|
|
369
|
+
if (updateSetting && form.primaryKey && rowProps.data[form.primaryKey]) {
|
|
370
|
+
modalOpen('update', rowProps.data[form.primaryKey]);
|
|
371
|
+
}
|
|
342
372
|
}
|
|
343
373
|
}
|
|
344
374
|
},
|
|
345
|
-
[form]
|
|
375
|
+
[form, settings, modalOpen]
|
|
346
376
|
);
|
|
347
377
|
|
|
348
378
|
const onRenderRow = useCallback((rowProps) => {
|
|
@@ -39,7 +39,7 @@ const CustomMultiValue = (props) => {
|
|
|
39
39
|
const { children, data, removeProps, settings, ...rest } = props;
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
<components.MultiValue {...rest}>
|
|
42
|
+
<components.MultiValue {...rest} data={data}>
|
|
43
43
|
<div className={styles.multiValue}>
|
|
44
44
|
<div className={styles.multiValueLabel}>
|
|
45
45
|
{children}
|
|
@@ -62,38 +62,51 @@ const CustomMultiValue = (props) => {
|
|
|
62
62
|
);
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
// Custom MultiValueRemove component with
|
|
65
|
+
// Custom MultiValueRemove component with proper removal handling
|
|
66
66
|
const CustomMultiValueRemove = (props) => {
|
|
67
|
-
const
|
|
67
|
+
const handleRemove = (e) => {
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
|
|
70
|
+
// Try to find the data by looking at the DOM structure
|
|
71
|
+
const removeButton = e.currentTarget;
|
|
72
|
+
const multiValueContainer = removeButton.closest('.visns-select__multi-value');
|
|
73
|
+
|
|
74
|
+
if (multiValueContainer) {
|
|
75
|
+
// Get the index of this multi-value item
|
|
76
|
+
const allMultiValues = removeButton.closest('.visns-select__value-container').querySelectorAll('.visns-select__multi-value');
|
|
77
|
+
const index = Array.from(allMultiValues).indexOf(multiValueContainer);
|
|
78
|
+
|
|
79
|
+
console.log('MultiSelect: Found index:', index);
|
|
80
|
+
|
|
81
|
+
// Get current value and remove the item at this index
|
|
82
|
+
const currentValue = props.selectProps?.value || [];
|
|
83
|
+
console.log('MultiSelect: Current value:', currentValue);
|
|
84
|
+
|
|
85
|
+
if (index >= 0 && index < currentValue.length) {
|
|
86
|
+
const itemToRemove = currentValue[index];
|
|
87
|
+
const newValue = currentValue.filter((_, i) => i !== index);
|
|
88
|
+
|
|
89
|
+
console.log('MultiSelect: Removing item at index', index, ':', itemToRemove);
|
|
90
|
+
console.log('MultiSelect: New value:', newValue);
|
|
91
|
+
|
|
92
|
+
// Call onChange with the filtered value and remove action
|
|
93
|
+
if (props.selectProps?.onChange) {
|
|
94
|
+
props.selectProps.onChange(newValue, {
|
|
95
|
+
action: 'remove-value',
|
|
96
|
+
removedValue: itemToRemove
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
68
102
|
|
|
69
103
|
return (
|
|
70
104
|
<components.MultiValueRemove
|
|
71
|
-
{...props}
|
|
105
|
+
{...props}
|
|
72
106
|
innerProps={{
|
|
73
|
-
...innerProps,
|
|
74
|
-
onClick:
|
|
75
|
-
|
|
76
|
-
console.log('MultiSelect: Event details:', e);
|
|
77
|
-
|
|
78
|
-
// Prevent event bubbling
|
|
79
|
-
e.stopPropagation();
|
|
80
|
-
e.preventDefault();
|
|
81
|
-
|
|
82
|
-
// Call the original handler
|
|
83
|
-
if (innerProps && innerProps.onClick) {
|
|
84
|
-
console.log('MultiSelect: Calling original onClick handler');
|
|
85
|
-
innerProps.onClick(e);
|
|
86
|
-
} else {
|
|
87
|
-
console.log('MultiSelect: No original onClick handler found');
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
onMouseDown: (e) => {
|
|
91
|
-
console.log('MultiSelect: Remove button mouse down');
|
|
92
|
-
e.stopPropagation();
|
|
93
|
-
if (innerProps && innerProps.onMouseDown) {
|
|
94
|
-
innerProps.onMouseDown(e);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
107
|
+
...props.innerProps,
|
|
108
|
+
onClick: handleRemove,
|
|
109
|
+
onMouseDown: (e) => e.stopPropagation()
|
|
97
110
|
}}
|
|
98
111
|
/>
|
|
99
112
|
);
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
/* Media queries for responsive design */
|
|
196
196
|
|
|
197
197
|
/* Tablet view (961px to 1024px) - Keep filter expanded in left container */
|
|
198
|
-
@media (max-width: 1024px) and (min-width:
|
|
198
|
+
@media (max-width: 1024px) and (min-width: 760px) {
|
|
199
199
|
/* Ensure filter remains visible and properly styled for tablets */
|
|
200
200
|
.tableFilter {
|
|
201
201
|
display: block;
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
/* Phone view (960px and below) - Use hamburger menu when navigation moves to top */
|
|
227
|
-
@media (max-width:
|
|
227
|
+
@media (max-width: 759px) {
|
|
228
228
|
.mobileToggle {
|
|
229
229
|
display: flex;
|
|
230
230
|
}
|