@apexcura/ui-components 0.0.11-Beta72 → 0.0.11-Beta73

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
@@ -363,7 +363,7 @@ var import_react13 = __toESM(require("react"));
363
363
  var import_antd11 = require("antd");
364
364
  var import_icons2 = require("@ant-design/icons");
365
365
  var AddMoreTable = (props) => {
366
- const { thead = [], tbody } = props;
366
+ const { thead, tbody } = props;
367
367
  const [tableData, setTableData] = (0, import_react13.useState)({});
368
368
  const [rows, setRows] = (0, import_react13.useState)(tbody || []);
369
369
  const onHandleChange = (name, value) => {
@@ -446,25 +446,27 @@ var AddMoreTable = (props) => {
446
446
  }
447
447
  };
448
448
  const dataSource = rows.map((eachRow, index) => {
449
- const subRowElements = eachRow.variable_data.map((variable, subIndex) => /* @__PURE__ */ import_react13.default.createElement("div", { key: subIndex, style: { display: "flex", marginBottom: 8 } }, Object.entries(variable).map(([key, value]) => {
450
- if (key !== "icons") {
451
- return /* @__PURE__ */ import_react13.default.createElement("div", { key, style: { marginRight: 8 } }, renderInputElement(value));
452
- }
453
- return null;
454
- }), /* @__PURE__ */ import_react13.default.createElement("div", null, 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)))));
455
- return {
456
- key: eachRow.id,
457
- index: index + 1,
458
- medicine: renderInputElement({
449
+ const subRow = eachRow.variable_data.map((variable, subIndex) => ({
450
+ key: `${eachRow.id}-${subIndex}`,
451
+ ...Object.fromEntries(Object.entries(variable).map(([key, value]) => {
452
+ if (key === "icons") {
453
+ return ["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)))];
454
+ } else {
455
+ return [key, renderInputElement(value)];
456
+ }
457
+ }))
458
+ }));
459
+ const rowData = {
460
+ "#": index + 1,
461
+ "Medicine": renderInputElement({
459
462
  element: eachRow.element,
460
463
  label: eachRow.label
461
464
  }),
462
- ...Object.fromEntries(
463
- thead.map((eachHeadEl) => [eachHeadEl.name, subRowElements])
464
- ),
465
+ subRow,
465
466
  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)))
466
467
  };
467
- });
468
+ return [rowData];
469
+ }).flat();
468
470
  if (!columns.some((col) => col.dataIndex === "actions")) {
469
471
  columns.push({
470
472
  title: "Actions",
package/dist/index.mjs CHANGED
@@ -316,7 +316,7 @@ import React12, { useState as useState3 } from "react";
316
316
  import { Table, Button as Button3 } from "antd";
317
317
  import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
318
318
  var AddMoreTable = (props) => {
319
- const { thead = [], tbody } = props;
319
+ const { thead, tbody } = props;
320
320
  const [tableData, setTableData] = useState3({});
321
321
  const [rows, setRows] = useState3(tbody || []);
322
322
  const onHandleChange = (name, value) => {
@@ -399,25 +399,27 @@ var AddMoreTable = (props) => {
399
399
  }
400
400
  };
401
401
  const dataSource = rows.map((eachRow, index) => {
402
- const subRowElements = eachRow.variable_data.map((variable, subIndex) => /* @__PURE__ */ React12.createElement("div", { key: subIndex, style: { display: "flex", marginBottom: 8 } }, Object.entries(variable).map(([key, value]) => {
403
- if (key !== "icons") {
404
- return /* @__PURE__ */ React12.createElement("div", { key, style: { marginRight: 8 } }, renderInputElement(value));
405
- }
406
- return null;
407
- }), /* @__PURE__ */ React12.createElement("div", null, 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)))));
408
- return {
409
- key: eachRow.id,
410
- index: index + 1,
411
- medicine: renderInputElement({
402
+ const subRow = eachRow.variable_data.map((variable, subIndex) => ({
403
+ key: `${eachRow.id}-${subIndex}`,
404
+ ...Object.fromEntries(Object.entries(variable).map(([key, value]) => {
405
+ if (key === "icons") {
406
+ return ["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)))];
407
+ } else {
408
+ return [key, renderInputElement(value)];
409
+ }
410
+ }))
411
+ }));
412
+ const rowData = {
413
+ "#": index + 1,
414
+ "Medicine": renderInputElement({
412
415
  element: eachRow.element,
413
416
  label: eachRow.label
414
417
  }),
415
- ...Object.fromEntries(
416
- thead.map((eachHeadEl) => [eachHeadEl.name, subRowElements])
417
- ),
418
+ subRow,
418
419
  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)))
419
420
  };
420
- });
421
+ return [rowData];
422
+ }).flat();
421
423
  if (!columns.some((col) => col.dataIndex === "actions")) {
422
424
  columns.push({
423
425
  title: "Actions",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta72",
3
+ "version": "0.0.11-Beta73",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",