@apexcura/ui-components 0.0.11-Beta70 → 0.0.11-Beta71

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) => {
@@ -430,11 +430,32 @@ var AddMoreTable = (props) => {
430
430
  });
431
431
  });
432
432
  };
433
- const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
434
- title: eachHeadEl.label,
435
- dataIndex: eachHeadEl.name,
436
- key: eachHeadEl.id
437
- })) : [];
433
+ const columns = [
434
+ {
435
+ title: "#",
436
+ dataIndex: "index",
437
+ key: "index"
438
+ },
439
+ {
440
+ title: "Medicine",
441
+ dataIndex: "medicine",
442
+ key: "medicine"
443
+ },
444
+ {
445
+ title: "Actions",
446
+ dataIndex: "actions",
447
+ key: "actions"
448
+ }
449
+ ];
450
+ if (thead) {
451
+ thead.forEach((eachHeadEl) => {
452
+ columns.push({
453
+ title: eachHeadEl.label,
454
+ dataIndex: eachHeadEl.name,
455
+ key: eachHeadEl.id
456
+ });
457
+ });
458
+ }
438
459
  const renderInputElement = (element) => {
439
460
  const { element: type, label } = element;
440
461
  if (type === "single-select") {
@@ -446,42 +467,54 @@ var AddMoreTable = (props) => {
446
467
  }
447
468
  };
448
469
  const dataSource = rows.map((eachRow, index) => {
449
- console.log("eachrow---------", eachRow);
450
470
  const subRow = eachRow.variable_data.map((variable, subIndex) => ({
451
471
  key: `${eachRow.id}-${subIndex}`,
452
472
  ...Object.fromEntries(Object.entries(variable).map(([key, value]) => {
453
473
  if (key === "icons") {
454
- 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)))];
474
+ return ["subRowActions", /* @__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)))];
455
475
  } else {
456
476
  return [key, renderInputElement(value)];
457
477
  }
458
478
  }))
459
479
  }));
460
- const rowData = {
461
- "#": index + 1,
462
- "Medicine": renderInputElement({
480
+ return {
481
+ key: eachRow.id,
482
+ index: index + 1,
483
+ medicine: renderInputElement({
463
484
  element: eachRow.element,
464
485
  label: eachRow.label
465
486
  }),
466
- subRow: [...subRow],
467
- 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)))
487
+ 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))),
488
+ subRows: subRow
468
489
  };
469
- return [rowData];
470
- }).flat();
471
- if (!columns.some((col) => col.dataIndex === "actions")) {
472
- columns.push({
473
- title: "Actions",
474
- dataIndex: "actions",
475
- key: "actions"
476
- });
477
- }
490
+ });
491
+ const expandedRowRender = (record) => {
492
+ return /* @__PURE__ */ import_react13.default.createElement(
493
+ import_antd11.Table,
494
+ {
495
+ columns: thead.map((eachHeadEl) => ({
496
+ title: eachHeadEl.label,
497
+ dataIndex: eachHeadEl.name,
498
+ key: eachHeadEl.id
499
+ })).concat([{
500
+ title: "SubRow Actions",
501
+ dataIndex: "subRowActions",
502
+ key: "subRowActions"
503
+ }]),
504
+ dataSource: record.subRows,
505
+ pagination: false,
506
+ bordered: true
507
+ }
508
+ );
509
+ };
478
510
  return /* @__PURE__ */ import_react13.default.createElement(
479
511
  import_antd11.Table,
480
512
  {
481
513
  columns,
482
514
  dataSource,
483
515
  pagination: false,
484
- bordered: true
516
+ bordered: true,
517
+ expandable: { expandedRowRender }
485
518
  }
486
519
  );
487
520
  };
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) => {
@@ -383,11 +383,32 @@ var AddMoreTable = (props) => {
383
383
  });
384
384
  });
385
385
  };
386
- const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
387
- title: eachHeadEl.label,
388
- dataIndex: eachHeadEl.name,
389
- key: eachHeadEl.id
390
- })) : [];
386
+ const columns = [
387
+ {
388
+ title: "#",
389
+ dataIndex: "index",
390
+ key: "index"
391
+ },
392
+ {
393
+ title: "Medicine",
394
+ dataIndex: "medicine",
395
+ key: "medicine"
396
+ },
397
+ {
398
+ title: "Actions",
399
+ dataIndex: "actions",
400
+ key: "actions"
401
+ }
402
+ ];
403
+ if (thead) {
404
+ thead.forEach((eachHeadEl) => {
405
+ columns.push({
406
+ title: eachHeadEl.label,
407
+ dataIndex: eachHeadEl.name,
408
+ key: eachHeadEl.id
409
+ });
410
+ });
411
+ }
391
412
  const renderInputElement = (element) => {
392
413
  const { element: type, label } = element;
393
414
  if (type === "single-select") {
@@ -399,42 +420,54 @@ var AddMoreTable = (props) => {
399
420
  }
400
421
  };
401
422
  const dataSource = rows.map((eachRow, index) => {
402
- console.log("eachrow---------", eachRow);
403
423
  const subRow = eachRow.variable_data.map((variable, subIndex) => ({
404
424
  key: `${eachRow.id}-${subIndex}`,
405
425
  ...Object.fromEntries(Object.entries(variable).map(([key, value]) => {
406
426
  if (key === "icons") {
407
- 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)))];
427
+ return ["subRowActions", /* @__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)))];
408
428
  } else {
409
429
  return [key, renderInputElement(value)];
410
430
  }
411
431
  }))
412
432
  }));
413
- const rowData = {
414
- "#": index + 1,
415
- "Medicine": renderInputElement({
433
+ return {
434
+ key: eachRow.id,
435
+ index: index + 1,
436
+ medicine: renderInputElement({
416
437
  element: eachRow.element,
417
438
  label: eachRow.label
418
439
  }),
419
- subRow: [...subRow],
420
- 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)))
440
+ 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))),
441
+ subRows: subRow
421
442
  };
422
- return [rowData];
423
- }).flat();
424
- if (!columns.some((col) => col.dataIndex === "actions")) {
425
- columns.push({
426
- title: "Actions",
427
- dataIndex: "actions",
428
- key: "actions"
429
- });
430
- }
443
+ });
444
+ const expandedRowRender = (record) => {
445
+ return /* @__PURE__ */ React12.createElement(
446
+ Table,
447
+ {
448
+ columns: thead.map((eachHeadEl) => ({
449
+ title: eachHeadEl.label,
450
+ dataIndex: eachHeadEl.name,
451
+ key: eachHeadEl.id
452
+ })).concat([{
453
+ title: "SubRow Actions",
454
+ dataIndex: "subRowActions",
455
+ key: "subRowActions"
456
+ }]),
457
+ dataSource: record.subRows,
458
+ pagination: false,
459
+ bordered: true
460
+ }
461
+ );
462
+ };
431
463
  return /* @__PURE__ */ React12.createElement(
432
464
  Table,
433
465
  {
434
466
  columns,
435
467
  dataSource,
436
468
  pagination: false,
437
- bordered: true
469
+ bordered: true,
470
+ expandable: { expandedRowRender }
438
471
  }
439
472
  );
440
473
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta70",
3
+ "version": "0.0.11-Beta71",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",