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

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,13 +378,20 @@ var AddMoreTable = (props) => {
378
378
  const newId = lastRow ? lastRow.id + 1 : 1;
379
379
  let newRow = {
380
380
  ...lastRow,
381
- id: newId,
382
- variable_data: lastRow ? lastRow.variable_data.map((item) => ({
383
- ...item,
384
- id: item.id + 1
385
- })) : []
381
+ id: newId
386
382
  };
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
+ }
387
393
  setRows((prevData) => [...prevData, newRow]);
394
+ console.log("rows----------", rows);
388
395
  };
389
396
  const onHandleDelete = (index) => {
390
397
  if (rows.length > 1) {
@@ -392,56 +399,6 @@ var AddMoreTable = (props) => {
392
399
  setRows(remainingRows);
393
400
  }
394
401
  };
395
- const onHandleVariableData = (rowId) => {
396
- setRows((prevRows) => prevRows.map((row) => {
397
- if (row.id === rowId) {
398
- const newVariableDataId = row.variable_data.length > 0 ? row.variable_data[row.variable_data.length - 1].id + 1 : 1;
399
- const newVariableData = {
400
- id: newVariableDataId,
401
- Route: {
402
- label: "Route",
403
- element: "single-select",
404
- type: "text"
405
- },
406
- Dose: {
407
- label: "Dose",
408
- element: "single-select",
409
- type: "text"
410
- },
411
- Frequency: {
412
- label: "Frequency",
413
- element: "single-select",
414
- type: "text"
415
- },
416
- When: {
417
- label: "When",
418
- element: "textarea",
419
- type: "text"
420
- },
421
- Duration: {
422
- label: "Duration",
423
- element: "textarea",
424
- type: "text"
425
- },
426
- Instructions: {
427
- label: "Instructions",
428
- element: "textarea",
429
- type: "text"
430
- },
431
- icons: { delete: "delete", plus: "plus" }
432
- };
433
- const updatedVariableData = [...row.variable_data, newVariableData].map((item, index, array) => ({
434
- ...item,
435
- icons: { delete: "delete", plus: index === array.length - 1 ? "plus" : void 0 }
436
- }));
437
- return {
438
- ...row,
439
- variable_data: updatedVariableData
440
- };
441
- }
442
- return row;
443
- }));
444
- };
445
402
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
446
403
  title: eachHeadEl.label,
447
404
  dataIndex: eachHeadEl.name,
@@ -469,16 +426,7 @@ var AddMoreTable = (props) => {
469
426
  rowElements[value.label] = renderInputElement(value);
470
427
  }
471
428
  if (key === "icons") {
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)));
429
+ console.log("-----------key", key);
482
430
  }
483
431
  });
484
432
  });
package/dist/index.mjs CHANGED
@@ -331,13 +331,20 @@ var AddMoreTable = (props) => {
331
331
  const newId = lastRow ? lastRow.id + 1 : 1;
332
332
  let newRow = {
333
333
  ...lastRow,
334
- id: newId,
335
- variable_data: lastRow ? lastRow.variable_data.map((item) => ({
336
- ...item,
337
- id: item.id + 1
338
- })) : []
334
+ id: newId
339
335
  };
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
+ }
340
346
  setRows((prevData) => [...prevData, newRow]);
347
+ console.log("rows----------", rows);
341
348
  };
342
349
  const onHandleDelete = (index) => {
343
350
  if (rows.length > 1) {
@@ -345,56 +352,6 @@ var AddMoreTable = (props) => {
345
352
  setRows(remainingRows);
346
353
  }
347
354
  };
348
- const onHandleVariableData = (rowId) => {
349
- setRows((prevRows) => prevRows.map((row) => {
350
- if (row.id === rowId) {
351
- const newVariableDataId = row.variable_data.length > 0 ? row.variable_data[row.variable_data.length - 1].id + 1 : 1;
352
- const newVariableData = {
353
- id: newVariableDataId,
354
- Route: {
355
- label: "Route",
356
- element: "single-select",
357
- type: "text"
358
- },
359
- Dose: {
360
- label: "Dose",
361
- element: "single-select",
362
- type: "text"
363
- },
364
- Frequency: {
365
- label: "Frequency",
366
- element: "single-select",
367
- type: "text"
368
- },
369
- When: {
370
- label: "When",
371
- element: "textarea",
372
- type: "text"
373
- },
374
- Duration: {
375
- label: "Duration",
376
- element: "textarea",
377
- type: "text"
378
- },
379
- Instructions: {
380
- label: "Instructions",
381
- element: "textarea",
382
- type: "text"
383
- },
384
- icons: { delete: "delete", plus: "plus" }
385
- };
386
- const updatedVariableData = [...row.variable_data, newVariableData].map((item, index, array) => ({
387
- ...item,
388
- icons: { delete: "delete", plus: index === array.length - 1 ? "plus" : void 0 }
389
- }));
390
- return {
391
- ...row,
392
- variable_data: updatedVariableData
393
- };
394
- }
395
- return row;
396
- }));
397
- };
398
355
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
399
356
  title: eachHeadEl.label,
400
357
  dataIndex: eachHeadEl.name,
@@ -422,16 +379,7 @@ var AddMoreTable = (props) => {
422
379
  rowElements[value.label] = renderInputElement(value);
423
380
  }
424
381
  if (key === "icons") {
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)));
382
+ console.log("-----------key", key);
435
383
  }
436
384
  });
437
385
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta26",
3
+ "version": "0.0.11-Beta27",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",