@apexcura/ui-components 0.0.11-Beta25 → 0.0.11-Beta26

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/dist/index.js CHANGED
@@ -378,18 +378,12 @@ var AddMoreTable = (props) => {
378
378
  const newId = lastRow ? lastRow.id + 1 : 1;
379
379
  let newRow = {
380
380
  ...lastRow,
381
- id: newId
381
+ id: newId,
382
+ variable_data: lastRow ? lastRow.variable_data.map((item) => ({
383
+ ...item,
384
+ id: item.id + 1
385
+ })) : []
382
386
  };
383
- if (newRow.variable_data && newRow.variable_data.length > 0) {
384
- const updatedVariableData = newRow.variable_data.map((item, index) => {
385
- const { icons, ...rest } = item;
386
- return {
387
- ...rest,
388
- icons: { delete: "", plus: index === newRow.variable_data.length - 1 ? "" : void 0 }
389
- };
390
- });
391
- newRow.variable_data = updatedVariableData;
392
- }
393
387
  setRows((prevData) => [...prevData, newRow]);
394
388
  };
395
389
  const onHandleDelete = (index) => {
@@ -475,7 +469,16 @@ var AddMoreTable = (props) => {
475
469
  rowElements[value.label] = renderInputElement(value);
476
470
  }
477
471
  if (key === "icons") {
478
- rowElements[`icons_${varIndex}`] = /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, "delete"), varIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onHandleVariableData(eachRow.id) }, "plus"));
472
+ rowElements[`icons_${varIndex}`] = /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => {
473
+ const updatedRows = rows.map((row) => {
474
+ if (row.id === eachRow.id) {
475
+ const updatedVariableData = row.variable_data.filter((item) => item.id !== variable.id);
476
+ return { ...row, variable_data: updatedVariableData };
477
+ }
478
+ return row;
479
+ });
480
+ setRows(updatedRows);
481
+ } }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), value && value.plus && /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onHandleVariableData(eachRow.id) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
479
482
  }
480
483
  });
481
484
  });
package/dist/index.mjs CHANGED
@@ -331,18 +331,12 @@ var AddMoreTable = (props) => {
331
331
  const newId = lastRow ? lastRow.id + 1 : 1;
332
332
  let newRow = {
333
333
  ...lastRow,
334
- id: newId
334
+ id: newId,
335
+ variable_data: lastRow ? lastRow.variable_data.map((item) => ({
336
+ ...item,
337
+ id: item.id + 1
338
+ })) : []
335
339
  };
336
- if (newRow.variable_data && newRow.variable_data.length > 0) {
337
- const updatedVariableData = newRow.variable_data.map((item, index) => {
338
- const { icons, ...rest } = item;
339
- return {
340
- ...rest,
341
- icons: { delete: "", plus: index === newRow.variable_data.length - 1 ? "" : void 0 }
342
- };
343
- });
344
- newRow.variable_data = updatedVariableData;
345
- }
346
340
  setRows((prevData) => [...prevData, newRow]);
347
341
  };
348
342
  const onHandleDelete = (index) => {
@@ -428,7 +422,16 @@ var AddMoreTable = (props) => {
428
422
  rowElements[value.label] = renderInputElement(value);
429
423
  }
430
424
  if (key === "icons") {
431
- rowElements[`icons_${varIndex}`] = /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, "delete"), varIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleVariableData(eachRow.id) }, "plus"));
425
+ rowElements[`icons_${varIndex}`] = /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => {
426
+ const updatedRows = rows.map((row) => {
427
+ if (row.id === eachRow.id) {
428
+ const updatedVariableData = row.variable_data.filter((item) => item.id !== variable.id);
429
+ return { ...row, variable_data: updatedVariableData };
430
+ }
431
+ return row;
432
+ });
433
+ setRows(updatedRows);
434
+ } }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), value && value.plus && /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleVariableData(eachRow.id) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
432
435
  }
433
436
  });
434
437
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta25",
3
+ "version": "0.0.11-Beta26",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",