@visns-studio/visns-components 4.4.9 → 4.4.10

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.
@@ -1152,9 +1152,9 @@ function Field({
1152
1152
  <thead>
1153
1153
  <tr>
1154
1154
  <th></th>
1155
- {tableRadioColumns.map((column, columnKey) => (
1155
+ {tableRadioColumns.map((column) => (
1156
1156
  <th
1157
- key={`${settings.id}-${columnKey.id}`}
1157
+ key={`${settings.id}-${column.id}`}
1158
1158
  style={{
1159
1159
  width: '250px',
1160
1160
  whiteSpace: 'nowrap',
@@ -1166,9 +1166,9 @@ function Field({
1166
1166
  </tr>
1167
1167
  </thead>
1168
1168
  <tbody>
1169
- {tableRadioRows.map((row, rowKey) => (
1169
+ {tableRadioRows.map((row) => (
1170
1170
  <tr
1171
- key={`table-radio-row-${settings.id}-${rowKey}`}
1171
+ key={`table-radio-row-${settings.id}-${row.id}`}
1172
1172
  >
1173
1173
  <td
1174
1174
  style={{
@@ -1177,27 +1177,25 @@ function Field({
1177
1177
  >
1178
1178
  {row.label}
1179
1179
  </td>
1180
- {tableRadioColumns.map(
1181
- (column, columnKey) => (
1182
- <td
1183
- key={`table-radio-cell-${settings.id}-${rowKey}-${columnKey}`}
1184
- >
1185
- <input
1186
- type="checkbox"
1187
- name={row.id}
1188
- data-id={settings.id}
1189
- onChange={
1190
- onChangeTableRadio
1191
- }
1192
- checked={
1193
- row.value === true
1194
- ? true
1195
- : false
1196
- }
1197
- />
1198
- </td>
1199
- )
1200
- )}
1180
+ {tableRadioColumns.map((column) => (
1181
+ <td
1182
+ key={`table-radio-cell-${settings.id}-${row.id}-${column.id}`}
1183
+ >
1184
+ {console.info(column, row)}
1185
+ <input
1186
+ type="checkbox"
1187
+ name={row.id}
1188
+ data-row-id={row.id}
1189
+ data-column-id={column.id}
1190
+ data-id={settings.id}
1191
+ onChange={onChangeTableRadio}
1192
+ checked={
1193
+ row.value?.[column.id] ===
1194
+ true
1195
+ }
1196
+ />
1197
+ </td>
1198
+ ))}
1201
1199
  </tr>
1202
1200
  ))}
1203
1201
  </tbody>
@@ -213,16 +213,11 @@ const GenericDynamic = ({
213
213
 
214
214
  const handleChangeTableRadio = (e) => {
215
215
  const {
216
- name,
217
- dataset: { id },
216
+ dataset: { id, rowId, columnId },
218
217
  } = e.target;
219
218
 
220
- // console.info('Checkbox changed:', { name, id });
221
-
222
219
  setActiveForm((prevActiveForm) => {
223
- // console.info('Previous activeForm:', prevActiveForm);
224
-
225
- // Find the form that matches the given id
220
+ // Find the form element that matches the given id
226
221
  const formKey = Object.keys(prevActiveForm).find(
227
222
  (key) => prevActiveForm[key].id === id
228
223
  );
@@ -234,15 +229,21 @@ const GenericDynamic = ({
234
229
  return prevActiveForm;
235
230
  }
236
231
 
237
- // console.info('Found formKey:', formKey);
238
-
239
232
  // Create a new rows array with toggled value properties
240
- const updatedRows = prevActiveForm[formKey].rows.map((row) => ({
241
- ...row,
242
- value: row.id === name ? !row.value : row.value ?? false, // Toggle value if it exists, else set default to false
243
- }));
244
-
245
- // console.info('Updated rows:', updatedRows);
233
+ const updatedRows = prevActiveForm[formKey].rows.map((row) => {
234
+ if (row.id === rowId) {
235
+ // Ensure the value is an object to handle multiple columns
236
+ const updatedValue = {
237
+ ...row.value,
238
+ [columnId]: !row.value?.[columnId], // Toggle the specific column value
239
+ };
240
+ return {
241
+ ...row,
242
+ value: updatedValue,
243
+ };
244
+ }
245
+ return row;
246
+ });
246
247
 
247
248
  // Return the updated activeForm state
248
249
  return {
@@ -255,6 +256,10 @@ const GenericDynamic = ({
255
256
  });
256
257
  };
257
258
 
259
+ useEffect(() => {
260
+ console.info(activeForm);
261
+ }, [activeForm]);
262
+
258
263
  const handleChangeAddTableTextRow = (id) => {
259
264
  setActiveForm((prevActiveForm) => {
260
265
  // Find the key of the form that matches the id
@@ -577,7 +582,7 @@ const GenericDynamic = ({
577
582
  if (templateStatus) {
578
583
  if (multiple) {
579
584
  if (activeForm.hasOwnProperty('id') === false) {
580
- handleAddNewForm(false);
585
+ // handleAddNewForm(false);
581
586
  }
582
587
  } else {
583
588
  if (Object.keys(activeForm).length === 0) {
package/package.json CHANGED
@@ -58,7 +58,7 @@
58
58
  "react-dom": "^17.0.1"
59
59
  },
60
60
  "name": "@visns-studio/visns-components",
61
- "version": "4.4.9",
61
+ "version": "4.4.10",
62
62
  "description": "Various packages to assist in the development of our Custom Applications.",
63
63
  "main": "index.js",
64
64
  "scripts": {