@apexcura/ui-components 0.0.11-Beta62 → 0.0.11-Beta65

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
@@ -382,13 +382,13 @@ var AddMoreTable = (props) => {
382
382
  variable_data: [
383
383
  {
384
384
  id: 1,
385
- Route: { label: "Route", element: "single-select", type: "text" },
385
+ Route: { label: "Route", element: "singleselect", type: "text" },
386
386
  Dose: { label: "Dose", element: "single-select", type: "text" },
387
387
  Frequency: { label: "Frequency", element: "single-select", type: "text" },
388
388
  When: { label: "When", element: "textarea", type: "text" },
389
389
  Duration: { label: "Duration", element: "textarea", type: "text" },
390
390
  Instructions: { label: "Instructions", element: "textarea", type: "text" },
391
- icons: { delete: "plusOutlined", add: "plusOutlined" }
391
+ icons: { delete: "plusOutlined", add: "plusOut-lined" }
392
392
  }
393
393
  ]
394
394
  };
@@ -445,33 +445,44 @@ var AddMoreTable = (props) => {
445
445
  const renderInputElement = (element) => {
446
446
  const { element: type, label } = element;
447
447
  if (type === "single-select") {
448
- return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { key: label, onChange: (value) => onHandleChange(label, value) });
448
+ return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
449
449
  } else if (type === "textarea") {
450
- return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { key: label, onChange: (value) => onHandleChange(label, value) });
450
+ return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
451
451
  } else {
452
452
  return null;
453
453
  }
454
454
  };
455
- const dataSource = rows.map((eachRow, index) => {
455
+ const dataSource = rows.flatMap((eachRow, index) => {
456
+ const rowData = [];
456
457
  const mainRow = {
457
- key: eachRow.id.toString(),
458
+ key: index.toString(),
458
459
  "#": index + 1,
459
- 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)), index === rows.length - 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: onHandleRows }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null))),
460
- subRows: eachRow.variable_data.map((variable, subIndex) => /* @__PURE__ */ import_react13.default.createElement("div", { key: subIndex, style: { marginBottom: "10px" } }, Object.entries(variable).map(([key, value]) => {
461
- if (key === "icons") {
462
- return /* @__PURE__ */ import_react13.default.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleSubRowsDelete(index, 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(index) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
463
- }
464
- if (value && value.element && value.label) {
465
- return renderInputElement(value);
466
- }
467
- return null;
468
- })))
469
- };
470
- return {
471
- ...mainRow,
472
460
  ...eachRow,
473
- subRows: /* @__PURE__ */ import_react13.default.createElement("div", null, mainRow.subRows)
461
+ 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)), index === rows.length - 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: onHandleRows }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)))
474
462
  };
463
+ const subRowElements = [];
464
+ if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
465
+ eachRow.variable_data.forEach((variable, subIndex) => {
466
+ const subRowElement = {};
467
+ Object.entries(variable).forEach(([key, value]) => {
468
+ if (key === "icons" && value) {
469
+ subRowElement["sub rows"] = /* @__PURE__ */ import_react13.default.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleSubRowsDelete(index, 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(index) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
470
+ } else if (value && value.element && value.label) {
471
+ subRowElement[value.label] = renderInputElement(value);
472
+ }
473
+ });
474
+ subRowElements.push(subRowElement);
475
+ });
476
+ }
477
+ rowData.push({
478
+ ...mainRow,
479
+ "Medicine": renderInputElement({
480
+ element: eachRow.element,
481
+ label: eachRow.label
482
+ }),
483
+ "sub rows": subRowElements
484
+ });
485
+ return rowData;
475
486
  });
476
487
  if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
477
488
  columns.push({
@@ -486,11 +497,7 @@ var AddMoreTable = (props) => {
486
497
  columns,
487
498
  dataSource,
488
499
  pagination: false,
489
- bordered: true,
490
- expandable: {
491
- expandedRowRender: (record) => /* @__PURE__ */ import_react13.default.createElement("div", null, record.subRows),
492
- rowExpandable: (record) => record.subRows.length > 0
493
- }
500
+ bordered: true
494
501
  }
495
502
  );
496
503
  };
package/dist/index.mjs CHANGED
@@ -335,13 +335,13 @@ var AddMoreTable = (props) => {
335
335
  variable_data: [
336
336
  {
337
337
  id: 1,
338
- Route: { label: "Route", element: "single-select", type: "text" },
338
+ Route: { label: "Route", element: "singleselect", type: "text" },
339
339
  Dose: { label: "Dose", element: "single-select", type: "text" },
340
340
  Frequency: { label: "Frequency", element: "single-select", type: "text" },
341
341
  When: { label: "When", element: "textarea", type: "text" },
342
342
  Duration: { label: "Duration", element: "textarea", type: "text" },
343
343
  Instructions: { label: "Instructions", element: "textarea", type: "text" },
344
- icons: { delete: "plusOutlined", add: "plusOutlined" }
344
+ icons: { delete: "plusOutlined", add: "plusOut-lined" }
345
345
  }
346
346
  ]
347
347
  };
@@ -398,33 +398,44 @@ var AddMoreTable = (props) => {
398
398
  const renderInputElement = (element) => {
399
399
  const { element: type, label } = element;
400
400
  if (type === "single-select") {
401
- return /* @__PURE__ */ React12.createElement(SingleSelectElement, { key: label, onChange: (value) => onHandleChange(label, value) });
401
+ return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
402
402
  } else if (type === "textarea") {
403
- return /* @__PURE__ */ React12.createElement(TextareaElement, { key: label, onChange: (value) => onHandleChange(label, value) });
403
+ return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
404
404
  } else {
405
405
  return null;
406
406
  }
407
407
  };
408
- const dataSource = rows.map((eachRow, index) => {
408
+ const dataSource = rows.flatMap((eachRow, index) => {
409
+ const rowData = [];
409
410
  const mainRow = {
410
- key: eachRow.id.toString(),
411
+ key: index.toString(),
411
412
  "#": index + 1,
412
- actions: /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null))),
413
- subRows: eachRow.variable_data.map((variable, subIndex) => /* @__PURE__ */ React12.createElement("div", { key: subIndex, style: { marginBottom: "10px" } }, Object.entries(variable).map(([key, value]) => {
414
- if (key === "icons") {
415
- return /* @__PURE__ */ React12.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsDelete(index, subIndex) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsAdd(index) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
416
- }
417
- if (value && value.element && value.label) {
418
- return renderInputElement(value);
419
- }
420
- return null;
421
- })))
422
- };
423
- return {
424
- ...mainRow,
425
413
  ...eachRow,
426
- subRows: /* @__PURE__ */ React12.createElement("div", null, mainRow.subRows)
414
+ actions: /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)))
427
415
  };
416
+ const subRowElements = [];
417
+ if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
418
+ eachRow.variable_data.forEach((variable, subIndex) => {
419
+ const subRowElement = {};
420
+ Object.entries(variable).forEach(([key, value]) => {
421
+ if (key === "icons" && value) {
422
+ subRowElement["sub rows"] = /* @__PURE__ */ React12.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsDelete(index, subIndex) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsAdd(index) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
423
+ } else if (value && value.element && value.label) {
424
+ subRowElement[value.label] = renderInputElement(value);
425
+ }
426
+ });
427
+ subRowElements.push(subRowElement);
428
+ });
429
+ }
430
+ rowData.push({
431
+ ...mainRow,
432
+ "Medicine": renderInputElement({
433
+ element: eachRow.element,
434
+ label: eachRow.label
435
+ }),
436
+ "sub rows": subRowElements
437
+ });
438
+ return rowData;
428
439
  });
429
440
  if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
430
441
  columns.push({
@@ -439,11 +450,7 @@ var AddMoreTable = (props) => {
439
450
  columns,
440
451
  dataSource,
441
452
  pagination: false,
442
- bordered: true,
443
- expandable: {
444
- expandedRowRender: (record) => /* @__PURE__ */ React12.createElement("div", null, record.subRows),
445
- rowExpandable: (record) => record.subRows.length > 0
446
- }
453
+ bordered: true
447
454
  }
448
455
  );
449
456
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta62",
3
+ "version": "0.0.11-Beta65",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",