@apexcura/ui-components 0.0.11-Beta94 → 0.0.11-Beta95

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
@@ -369,10 +369,10 @@ var AddMoreTable = (props) => {
369
369
  const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
370
370
  let newRow = {
371
371
  id: newId,
372
+ Medicine: { label: "Medicine", element: "textarea", type: "text" },
372
373
  variable_data: [
373
374
  {
374
375
  id: 1,
375
- Medicine: { label: "Medicine", element: "single-select", type: "text" },
376
376
  Route: { label: "Route", element: "single-select", type: "text" },
377
377
  Dose: { label: "Dose", element: "single-select", type: "text" },
378
378
  Frequency: { label: "Frequency", element: "single-select", type: "text" },
@@ -394,7 +394,6 @@ var AddMoreTable = (props) => {
394
394
  if (index === rowIndex) {
395
395
  const newSubRow = {
396
396
  id: row.variable_data.length + 1,
397
- Medicine: { label: "Medicine", element: "single-select", type: "text" },
398
397
  Route: { label: "Route", element: "single-select", type: "text" },
399
398
  Dose: { label: "Dose", element: "single-select", type: "text" },
400
399
  Frequency: { label: "Frequency", element: "single-select", type: "text" },
@@ -442,29 +441,42 @@ var AddMoreTable = (props) => {
442
441
  return null;
443
442
  }
444
443
  };
445
- const dataSource = rows.flatMap((eachRow, rowIndex) => {
446
- return eachRow.variable_data.map((variable, subIndex) => {
447
- const rowData = {
448
- key: `${eachRow.id}-${variable.id}`,
449
- "#": rowIndex + 1,
450
- "Medicine": renderInputElement(variable.Medicine)
451
- };
444
+ const dataSource = rows.map((eachRow, rowIndex) => {
445
+ const mainRowData = {
446
+ key: eachRow.id,
447
+ "#": rowIndex + 1,
448
+ "Medicine": renderInputElement(eachRow.Medicine)
449
+ };
450
+ eachRow.variable_data.forEach((variable, subIndex) => {
452
451
  Object.keys(variable).forEach((key) => {
453
452
  if (key === "SubRows") {
454
- rowData[`${key}`] = /* @__PURE__ */ import_react13.default.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleSubRowsDelete(rowIndex, subIndex) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleSubRowsAdd(rowIndex) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
455
- } else if (key !== "Medicine") {
456
- rowData[`${key}`] = renderInputElement(variable[key]);
453
+ mainRowData[`${key}_${subIndex}`] = /* @__PURE__ */ import_react13.default.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleSubRowsDelete(rowIndex, subIndex) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleSubRowsAdd(rowIndex) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
454
+ } else {
455
+ mainRowData[`${key}_${subIndex}`] = renderInputElement(variable[key]);
457
456
  }
458
457
  });
459
- rowData.actions = /* @__PURE__ */ import_react13.default.createElement("div", null, /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), rowIndex === rows.length - 1 && subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: onHandleRows }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
460
- return rowData;
461
458
  });
459
+ mainRowData.actions = /* @__PURE__ */ import_react13.default.createElement("div", null, /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), rowIndex === rows.length - 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: onHandleRows }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
460
+ return mainRowData;
462
461
  });
463
462
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
464
463
  title: eachHeadEl.label,
465
464
  dataIndex: eachHeadEl.name,
466
465
  key: eachHeadEl.id
467
466
  })) : [];
467
+ rows.forEach((eachRow) => {
468
+ eachRow.variable_data.forEach((variable, subIndex) => {
469
+ Object.keys(variable).forEach((key) => {
470
+ if (!columns.some((col) => col.dataIndex === `${key}_${subIndex}`)) {
471
+ columns.push({
472
+ title: `${key}`,
473
+ dataIndex: `${key}_${subIndex}`,
474
+ key: `${key}_${subIndex}`
475
+ });
476
+ }
477
+ });
478
+ });
479
+ });
468
480
  if (!columns.some((col) => col.dataIndex === "actions")) {
469
481
  columns.push({
470
482
  title: "Actions",
package/dist/index.mjs CHANGED
@@ -322,10 +322,10 @@ var AddMoreTable = (props) => {
322
322
  const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
323
323
  let newRow = {
324
324
  id: newId,
325
+ Medicine: { label: "Medicine", element: "textarea", type: "text" },
325
326
  variable_data: [
326
327
  {
327
328
  id: 1,
328
- Medicine: { label: "Medicine", element: "single-select", type: "text" },
329
329
  Route: { label: "Route", element: "single-select", type: "text" },
330
330
  Dose: { label: "Dose", element: "single-select", type: "text" },
331
331
  Frequency: { label: "Frequency", element: "single-select", type: "text" },
@@ -347,7 +347,6 @@ var AddMoreTable = (props) => {
347
347
  if (index === rowIndex) {
348
348
  const newSubRow = {
349
349
  id: row.variable_data.length + 1,
350
- Medicine: { label: "Medicine", element: "single-select", type: "text" },
351
350
  Route: { label: "Route", element: "single-select", type: "text" },
352
351
  Dose: { label: "Dose", element: "single-select", type: "text" },
353
352
  Frequency: { label: "Frequency", element: "single-select", type: "text" },
@@ -395,29 +394,42 @@ var AddMoreTable = (props) => {
395
394
  return null;
396
395
  }
397
396
  };
398
- const dataSource = rows.flatMap((eachRow, rowIndex) => {
399
- return eachRow.variable_data.map((variable, subIndex) => {
400
- const rowData = {
401
- key: `${eachRow.id}-${variable.id}`,
402
- "#": rowIndex + 1,
403
- "Medicine": renderInputElement(variable.Medicine)
404
- };
397
+ const dataSource = rows.map((eachRow, rowIndex) => {
398
+ const mainRowData = {
399
+ key: eachRow.id,
400
+ "#": rowIndex + 1,
401
+ "Medicine": renderInputElement(eachRow.Medicine)
402
+ };
403
+ eachRow.variable_data.forEach((variable, subIndex) => {
405
404
  Object.keys(variable).forEach((key) => {
406
405
  if (key === "SubRows") {
407
- rowData[`${key}`] = /* @__PURE__ */ React12.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsDelete(rowIndex, subIndex) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsAdd(rowIndex) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
408
- } else if (key !== "Medicine") {
409
- rowData[`${key}`] = renderInputElement(variable[key]);
406
+ mainRowData[`${key}_${subIndex}`] = /* @__PURE__ */ React12.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsDelete(rowIndex, subIndex) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsAdd(rowIndex) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
407
+ } else {
408
+ mainRowData[`${key}_${subIndex}`] = renderInputElement(variable[key]);
410
409
  }
411
410
  });
412
- rowData.actions = /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), rowIndex === rows.length - 1 && subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
413
- return rowData;
414
411
  });
412
+ mainRowData.actions = /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), rowIndex === rows.length - 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
413
+ return mainRowData;
415
414
  });
416
415
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
417
416
  title: eachHeadEl.label,
418
417
  dataIndex: eachHeadEl.name,
419
418
  key: eachHeadEl.id
420
419
  })) : [];
420
+ rows.forEach((eachRow) => {
421
+ eachRow.variable_data.forEach((variable, subIndex) => {
422
+ Object.keys(variable).forEach((key) => {
423
+ if (!columns.some((col) => col.dataIndex === `${key}_${subIndex}`)) {
424
+ columns.push({
425
+ title: `${key}`,
426
+ dataIndex: `${key}_${subIndex}`,
427
+ key: `${key}_${subIndex}`
428
+ });
429
+ }
430
+ });
431
+ });
432
+ });
421
433
  if (!columns.some((col) => col.dataIndex === "actions")) {
422
434
  columns.push({
423
435
  title: "Actions",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta94",
3
+ "version": "0.0.11-Beta95",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",