@apexcura/ui-components 0.0.11-Beta21 → 0.0.11-Beta23

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
@@ -375,17 +375,59 @@ var AddMoreTable = (props) => {
375
375
  };
376
376
  const onHandleRows = () => {
377
377
  const lastRow = rows[rows.length - 1];
378
- const newId = lastRow ? lastRow.id + 1 : lastRow.id;
379
- const newRow = {
380
- ...lastRow,
381
- id: newId
382
- };
378
+ const newId = lastRow ? lastRow.id + 1 : 1;
379
+ let newRow;
380
+ if (lastRow && lastRow.variable_data && lastRow.variable_data.length > 0) {
381
+ const lastVariable = lastRow.variable_data[lastRow.variable_data.length - 1];
382
+ const newVariableId = lastVariable.id + 1;
383
+ newRow = {
384
+ ...lastRow,
385
+ id: newId,
386
+ variable_data: [
387
+ ...lastRow.variable_data,
388
+ {
389
+ id: newVariableId,
390
+ icon: {}
391
+ }
392
+ ]
393
+ };
394
+ } else {
395
+ newRow = {
396
+ ...lastRow,
397
+ id: newId
398
+ };
399
+ }
383
400
  setRows((prevData) => [...prevData, newRow]);
384
401
  };
385
402
  const onHandleDelete = (index) => {
386
403
  const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
387
404
  setRows(remainingRows);
388
405
  };
406
+ const onAddVariableData = (rowIndex) => {
407
+ console.log("rowIndex==>", rowIndex);
408
+ setRows((prevRows) => {
409
+ console.log("prevRows===>", prevRows);
410
+ return prevRows.map((row, index) => {
411
+ console.log("row", row);
412
+ console.log("index", index);
413
+ if (index === rowIndex && row.variable_data && row.variable_data.length > 0) {
414
+ const lastVariable = row.variable_data[row.variable_data.length - 1];
415
+ const newVariableId = lastVariable.id + 1;
416
+ return {
417
+ ...row,
418
+ variable_data: [
419
+ ...row.variable_data,
420
+ {
421
+ id: newVariableId,
422
+ icon: {}
423
+ }
424
+ ]
425
+ };
426
+ }
427
+ return row;
428
+ });
429
+ });
430
+ };
389
431
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
390
432
  title: eachHeadEl.label,
391
433
  dataIndex: eachHeadEl.name,
@@ -414,28 +456,13 @@ var AddMoreTable = (props) => {
414
456
  }
415
457
  });
416
458
  });
417
- if (eachRow.variable_data.length > 0) {
418
- const addIconObject = {
419
- id: { id: eachRow.variable_data.length + 1 },
420
- Route: { label: "Route", element: "single-select", type: "text" },
421
- Dose: { label: "Dose", element: "single-select", type: "text" },
422
- Frequency: { label: "Frequency", element: "single-select", type: "text" },
423
- When: { label: "When", element: "textarea", type: "text" },
424
- Duration: { label: "Duration", element: "textarea", type: "text" },
425
- Instructions: { label: "Instructions", element: "textarea", type: "text" },
426
- addIcon: /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => console.log("Add more clicked") }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null))
427
- };
428
- console.log("eachrow----------", eachRow);
429
- rowElements["AddMoreIcon"] = addIconObject.addIcon;
430
- }
431
- console.log("RowElement", rowElements);
432
459
  }
433
460
  return {
434
461
  key: index.toString(),
435
462
  "#": index + 1,
436
463
  ...eachRow,
437
464
  ...rowElements,
438
- actions: /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ import_react13.default.createElement("button", { onClick: onHandleRows }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)))
465
+ actions: /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onAddVariableData(index) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)), /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ import_react13.default.createElement("button", { onClick: onHandleRows }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)))
439
466
  };
440
467
  });
441
468
  if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
package/dist/index.mjs CHANGED
@@ -328,17 +328,59 @@ var AddMoreTable = (props) => {
328
328
  };
329
329
  const onHandleRows = () => {
330
330
  const lastRow = rows[rows.length - 1];
331
- const newId = lastRow ? lastRow.id + 1 : lastRow.id;
332
- const newRow = {
333
- ...lastRow,
334
- id: newId
335
- };
331
+ const newId = lastRow ? lastRow.id + 1 : 1;
332
+ let newRow;
333
+ if (lastRow && lastRow.variable_data && lastRow.variable_data.length > 0) {
334
+ const lastVariable = lastRow.variable_data[lastRow.variable_data.length - 1];
335
+ const newVariableId = lastVariable.id + 1;
336
+ newRow = {
337
+ ...lastRow,
338
+ id: newId,
339
+ variable_data: [
340
+ ...lastRow.variable_data,
341
+ {
342
+ id: newVariableId,
343
+ icon: {}
344
+ }
345
+ ]
346
+ };
347
+ } else {
348
+ newRow = {
349
+ ...lastRow,
350
+ id: newId
351
+ };
352
+ }
336
353
  setRows((prevData) => [...prevData, newRow]);
337
354
  };
338
355
  const onHandleDelete = (index) => {
339
356
  const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
340
357
  setRows(remainingRows);
341
358
  };
359
+ const onAddVariableData = (rowIndex) => {
360
+ console.log("rowIndex==>", rowIndex);
361
+ setRows((prevRows) => {
362
+ console.log("prevRows===>", prevRows);
363
+ return prevRows.map((row, index) => {
364
+ console.log("row", row);
365
+ console.log("index", index);
366
+ if (index === rowIndex && row.variable_data && row.variable_data.length > 0) {
367
+ const lastVariable = row.variable_data[row.variable_data.length - 1];
368
+ const newVariableId = lastVariable.id + 1;
369
+ return {
370
+ ...row,
371
+ variable_data: [
372
+ ...row.variable_data,
373
+ {
374
+ id: newVariableId,
375
+ icon: {}
376
+ }
377
+ ]
378
+ };
379
+ }
380
+ return row;
381
+ });
382
+ });
383
+ };
342
384
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
343
385
  title: eachHeadEl.label,
344
386
  dataIndex: eachHeadEl.name,
@@ -367,28 +409,13 @@ var AddMoreTable = (props) => {
367
409
  }
368
410
  });
369
411
  });
370
- if (eachRow.variable_data.length > 0) {
371
- const addIconObject = {
372
- id: { id: eachRow.variable_data.length + 1 },
373
- Route: { label: "Route", element: "single-select", type: "text" },
374
- Dose: { label: "Dose", element: "single-select", type: "text" },
375
- Frequency: { label: "Frequency", element: "single-select", type: "text" },
376
- When: { label: "When", element: "textarea", type: "text" },
377
- Duration: { label: "Duration", element: "textarea", type: "text" },
378
- Instructions: { label: "Instructions", element: "textarea", type: "text" },
379
- addIcon: /* @__PURE__ */ React12.createElement("button", { onClick: () => console.log("Add more clicked") }, /* @__PURE__ */ React12.createElement(PlusOutlined, null))
380
- };
381
- console.log("eachrow----------", eachRow);
382
- rowElements["AddMoreIcon"] = addIconObject.addIcon;
383
- }
384
- console.log("RowElement", rowElements);
385
412
  }
386
413
  return {
387
414
  key: index.toString(),
388
415
  "#": index + 1,
389
416
  ...eachRow,
390
417
  ...rowElements,
391
- actions: /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ React12.createElement("button", { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)))
418
+ actions: /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => onAddVariableData(index) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)), /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ React12.createElement("button", { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)))
392
419
  };
393
420
  });
394
421
  if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta21",
3
+ "version": "0.0.11-Beta23",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",