@apexcura/ui-components 0.0.11-Beta85 → 0.0.11-Beta87

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
@@ -364,12 +364,7 @@ var import_antd11 = require("antd");
364
364
  var import_icons2 = require("@ant-design/icons");
365
365
  var AddMoreTable = (props) => {
366
366
  const { thead, tbody } = props;
367
- const [tableData, setTableData] = (0, import_react13.useState)({});
368
367
  const [rows, setRows] = (0, import_react13.useState)(tbody || []);
369
- const onHandleChange = (name, value) => {
370
- setTableData((prev) => ({ ...prev, [name]: value }));
371
- console.log(tableData);
372
- };
373
368
  const onHandleRows = () => {
374
369
  const lastRow = rows[rows.length - 1];
375
370
  const newId = lastRow ? lastRow.id + 1 : 1;
@@ -433,17 +428,20 @@ var AddMoreTable = (props) => {
433
428
  (0, import_react13.useEffect)(() => {
434
429
  console.log(rows);
435
430
  }, [rows]);
436
- const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
437
- title: eachHeadEl.label,
438
- dataIndex: eachHeadEl.name,
439
- key: eachHeadEl.id
440
- })) : [];
441
431
  const renderInputElement = (element) => {
442
432
  const { element: type, label } = element;
443
433
  if (type === "single-select") {
444
- return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
434
+ let onHandleChange2 = function(label2, value) {
435
+ throw new Error("Function not implemented.");
436
+ };
437
+ var onHandleChange = onHandleChange2;
438
+ return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value) => onHandleChange2(label, value) });
445
439
  } else if (type === "textarea") {
446
- return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
440
+ let onHandleChange2 = function(label2, value) {
441
+ throw new Error("Function not implemented.");
442
+ };
443
+ var onHandleChange = onHandleChange2;
444
+ return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value) => onHandleChange2(label, value) });
447
445
  } else {
448
446
  return null;
449
447
  }
@@ -452,17 +450,27 @@ var AddMoreTable = (props) => {
452
450
  const rowData = {
453
451
  key: eachRow.id,
454
452
  "#": index + 1,
455
- Medicine: renderInputElement({
456
- element: eachRow.element,
457
- label: eachRow.label
458
- }),
453
+ ...eachRow.variable_data.reduce((acc, variable, subIndex) => {
454
+ Object.keys(variable).forEach((key) => {
455
+ if (key === "SubRows") {
456
+ return;
457
+ }
458
+ acc[`${key}_${subIndex}`] = renderInputElement(variable[key]);
459
+ });
460
+ return acc;
461
+ }, {}),
459
462
  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
463
  };
461
- eachRow.variable_data.forEach((variable, subIndex) => {
462
- rowData[`subRow-${subIndex}`] = /* @__PURE__ */ import_react13.default.createElement("div", { key: subIndex, style: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ import_react13.default.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.Route)), /* @__PURE__ */ import_react13.default.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.Dose)), /* @__PURE__ */ import_react13.default.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.Frequency)), /* @__PURE__ */ import_react13.default.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.When)), /* @__PURE__ */ import_react13.default.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.Duration)), /* @__PURE__ */ import_react13.default.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.Instructions)), /* @__PURE__ */ import_react13.default.createElement("div", { style: { flex: 1 } }, 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 (eachRow.variable_data.length > 1) {
465
+ rowData[`SubRows`] = /* @__PURE__ */ import_react13.default.createElement("div", null, eachRow.variable_data.map((variable, subIndex) => /* @__PURE__ */ import_react13.default.createElement("div", { key: subIndex }, /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleSubRowsDelete(index, subIndex) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)))), /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleSubRowsAdd(index) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
466
+ }
464
467
  return rowData;
465
468
  });
469
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
470
+ title: eachHeadEl.label,
471
+ dataIndex: eachHeadEl.name,
472
+ key: eachHeadEl.id
473
+ })) : [];
466
474
  if (!columns.some((col) => col.dataIndex === "actions")) {
467
475
  columns.push({
468
476
  title: "Actions",
@@ -470,22 +478,6 @@ var AddMoreTable = (props) => {
470
478
  key: "actions"
471
479
  });
472
480
  }
473
- const subRowColumns = [
474
- { title: "Route", dataIndex: "Route", key: "Route" },
475
- { title: "Dose", dataIndex: "Dose", key: "Dose" },
476
- { title: "Frequency", dataIndex: "Frequency", key: "Frequency" },
477
- { title: "When", dataIndex: "When", key: "When" },
478
- { title: "Duration", dataIndex: "Duration", key: "Duration" },
479
- { title: "Instructions", dataIndex: "Instructions", key: "Instructions" },
480
- { title: "SubRows", dataIndex: "SubRows", key: "SubRows" }
481
- ];
482
- subRowColumns.forEach((col, index) => {
483
- columns.push({
484
- title: col.title,
485
- dataIndex: `subRow-${index}`,
486
- key: `subRow-${index}`
487
- });
488
- });
489
481
  return /* @__PURE__ */ import_react13.default.createElement(
490
482
  import_antd11.Table,
491
483
  {
package/dist/index.mjs CHANGED
@@ -317,12 +317,7 @@ import { Table, Button as Button3 } from "antd";
317
317
  import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
318
318
  var AddMoreTable = (props) => {
319
319
  const { thead, tbody } = props;
320
- const [tableData, setTableData] = useState3({});
321
320
  const [rows, setRows] = useState3(tbody || []);
322
- const onHandleChange = (name, value) => {
323
- setTableData((prev) => ({ ...prev, [name]: value }));
324
- console.log(tableData);
325
- };
326
321
  const onHandleRows = () => {
327
322
  const lastRow = rows[rows.length - 1];
328
323
  const newId = lastRow ? lastRow.id + 1 : 1;
@@ -386,17 +381,20 @@ var AddMoreTable = (props) => {
386
381
  useEffect(() => {
387
382
  console.log(rows);
388
383
  }, [rows]);
389
- const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
390
- title: eachHeadEl.label,
391
- dataIndex: eachHeadEl.name,
392
- key: eachHeadEl.id
393
- })) : [];
394
384
  const renderInputElement = (element) => {
395
385
  const { element: type, label } = element;
396
386
  if (type === "single-select") {
397
- return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
387
+ let onHandleChange2 = function(label2, value) {
388
+ throw new Error("Function not implemented.");
389
+ };
390
+ var onHandleChange = onHandleChange2;
391
+ return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange2(label, value) });
398
392
  } else if (type === "textarea") {
399
- return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
393
+ let onHandleChange2 = function(label2, value) {
394
+ throw new Error("Function not implemented.");
395
+ };
396
+ var onHandleChange = onHandleChange2;
397
+ return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value) => onHandleChange2(label, value) });
400
398
  } else {
401
399
  return null;
402
400
  }
@@ -405,17 +403,27 @@ var AddMoreTable = (props) => {
405
403
  const rowData = {
406
404
  key: eachRow.id,
407
405
  "#": index + 1,
408
- Medicine: renderInputElement({
409
- element: eachRow.element,
410
- label: eachRow.label
411
- }),
406
+ ...eachRow.variable_data.reduce((acc, variable, subIndex) => {
407
+ Object.keys(variable).forEach((key) => {
408
+ if (key === "SubRows") {
409
+ return;
410
+ }
411
+ acc[`${key}_${subIndex}`] = renderInputElement(variable[key]);
412
+ });
413
+ return acc;
414
+ }, {}),
412
415
  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
416
  };
414
- eachRow.variable_data.forEach((variable, subIndex) => {
415
- rowData[`subRow-${subIndex}`] = /* @__PURE__ */ React12.createElement("div", { key: subIndex, style: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ React12.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.Route)), /* @__PURE__ */ React12.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.Dose)), /* @__PURE__ */ React12.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.Frequency)), /* @__PURE__ */ React12.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.When)), /* @__PURE__ */ React12.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.Duration)), /* @__PURE__ */ React12.createElement("div", { style: { flex: 1 } }, renderInputElement(variable.Instructions)), /* @__PURE__ */ React12.createElement("div", { style: { flex: 1 } }, 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 (eachRow.variable_data.length > 1) {
418
+ rowData[`SubRows`] = /* @__PURE__ */ React12.createElement("div", null, eachRow.variable_data.map((variable, subIndex) => /* @__PURE__ */ React12.createElement("div", { key: subIndex }, /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsDelete(index, subIndex) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)))), /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsAdd(index) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
419
+ }
417
420
  return rowData;
418
421
  });
422
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
423
+ title: eachHeadEl.label,
424
+ dataIndex: eachHeadEl.name,
425
+ key: eachHeadEl.id
426
+ })) : [];
419
427
  if (!columns.some((col) => col.dataIndex === "actions")) {
420
428
  columns.push({
421
429
  title: "Actions",
@@ -423,22 +431,6 @@ var AddMoreTable = (props) => {
423
431
  key: "actions"
424
432
  });
425
433
  }
426
- const subRowColumns = [
427
- { title: "Route", dataIndex: "Route", key: "Route" },
428
- { title: "Dose", dataIndex: "Dose", key: "Dose" },
429
- { title: "Frequency", dataIndex: "Frequency", key: "Frequency" },
430
- { title: "When", dataIndex: "When", key: "When" },
431
- { title: "Duration", dataIndex: "Duration", key: "Duration" },
432
- { title: "Instructions", dataIndex: "Instructions", key: "Instructions" },
433
- { title: "SubRows", dataIndex: "SubRows", key: "SubRows" }
434
- ];
435
- subRowColumns.forEach((col, index) => {
436
- columns.push({
437
- title: col.title,
438
- dataIndex: `subRow-${index}`,
439
- key: `subRow-${index}`
440
- });
441
- });
442
434
  return /* @__PURE__ */ React12.createElement(
443
435
  Table,
444
436
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta85",
3
+ "version": "0.0.11-Beta87",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",