@apexcura/ui-components 0.0.11-Beta40 → 0.0.11-Beta41

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
@@ -388,8 +388,28 @@ var AddMoreTable = (props) => {
388
388
  setRows(remainingRows);
389
389
  }
390
390
  };
391
- const onHandleSubRowsAdd = () => {
392
- console.log(rows);
391
+ const onHandleSubRowsAdd = (rowIndex) => {
392
+ setRows((prevRows) => {
393
+ return prevRows.map((row, index) => {
394
+ if (index === rowIndex) {
395
+ const newSubRow = {
396
+ id: row.variable_data.length + 1,
397
+ Route: { label: "Route", element: "single-select", type: "text" },
398
+ Dose: { label: "Dose", element: "single-select", type: "text" },
399
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
400
+ When: { label: "When", element: "textarea", type: "text" },
401
+ Duration: { label: "Duration", element: "textarea", type: "text" },
402
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
403
+ icons: { delete: "plusOutlined", add: "plusOutlined" }
404
+ };
405
+ return {
406
+ ...row,
407
+ variable_data: [...row.variable_data, newSubRow]
408
+ };
409
+ }
410
+ return row;
411
+ });
412
+ });
393
413
  };
394
414
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
395
415
  title: eachHeadEl.label,
@@ -417,7 +437,7 @@ var AddMoreTable = (props) => {
417
437
  if (key === "icons" && value) {
418
438
  {
419
439
  eachRow.variable_data.map((variable2, subIndex) => {
420
- rowElements["sub rows"] = /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, eachRow.variable_data.length > 1 && /* @__PURE__ */ import_react13.default.createElement("button", null, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ import_react13.default.createElement("button", { onClick: onHandleSubRowsAdd }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
440
+ rowElements["sub rows"] = /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, eachRow.variable_data.length > 1 && /* @__PURE__ */ import_react13.default.createElement("button", null, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onHandleSubRowsAdd(index) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
421
441
  });
422
442
  }
423
443
  } else if (value && value.element && value.label) {
package/dist/index.mjs CHANGED
@@ -341,8 +341,28 @@ var AddMoreTable = (props) => {
341
341
  setRows(remainingRows);
342
342
  }
343
343
  };
344
- const onHandleSubRowsAdd = () => {
345
- console.log(rows);
344
+ const onHandleSubRowsAdd = (rowIndex) => {
345
+ setRows((prevRows) => {
346
+ return prevRows.map((row, index) => {
347
+ if (index === rowIndex) {
348
+ const newSubRow = {
349
+ id: row.variable_data.length + 1,
350
+ Route: { label: "Route", element: "single-select", type: "text" },
351
+ Dose: { label: "Dose", element: "single-select", type: "text" },
352
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
353
+ When: { label: "When", element: "textarea", type: "text" },
354
+ Duration: { label: "Duration", element: "textarea", type: "text" },
355
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
356
+ icons: { delete: "plusOutlined", add: "plusOutlined" }
357
+ };
358
+ return {
359
+ ...row,
360
+ variable_data: [...row.variable_data, newSubRow]
361
+ };
362
+ }
363
+ return row;
364
+ });
365
+ });
346
366
  };
347
367
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
348
368
  title: eachHeadEl.label,
@@ -370,7 +390,7 @@ var AddMoreTable = (props) => {
370
390
  if (key === "icons" && value) {
371
391
  {
372
392
  eachRow.variable_data.map((variable2, subIndex) => {
373
- rowElements["sub rows"] = /* @__PURE__ */ React12.createElement(React12.Fragment, null, eachRow.variable_data.length > 1 && /* @__PURE__ */ React12.createElement("button", null, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement("button", { onClick: onHandleSubRowsAdd }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
393
+ rowElements["sub rows"] = /* @__PURE__ */ React12.createElement(React12.Fragment, null, eachRow.variable_data.length > 1 && /* @__PURE__ */ React12.createElement("button", null, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleSubRowsAdd(index) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
374
394
  });
375
395
  }
376
396
  } else if (value && value.element && value.label) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta40",
3
+ "version": "0.0.11-Beta41",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",