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

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
@@ -430,32 +430,11 @@ var AddMoreTable = (props) => {
430
430
  });
431
431
  });
432
432
  };
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
- }
433
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
434
+ title: eachHeadEl.label,
435
+ dataIndex: eachHeadEl.name,
436
+ key: eachHeadEl.id
437
+ })) : [];
459
438
  const renderInputElement = (element) => {
460
439
  const { element: type, label } = element;
461
440
  if (type === "single-select") {
@@ -467,16 +446,12 @@ var AddMoreTable = (props) => {
467
446
  }
468
447
  };
469
448
  const dataSource = rows.map((eachRow, index) => {
470
- const subRow = eachRow.variable_data.map((variable, subIndex) => ({
471
- key: `${eachRow.id}-${subIndex}`,
472
- ...Object.fromEntries(Object.entries(variable).map(([key, value]) => {
473
- if (key === "icons") {
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)))];
475
- } else {
476
- return [key, renderInputElement(value)];
477
- }
478
- }))
479
- }));
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)))));
480
455
  return {
481
456
  key: eachRow.id,
482
457
  index: index + 1,
@@ -484,37 +459,26 @@ var AddMoreTable = (props) => {
484
459
  element: eachRow.element,
485
460
  label: eachRow.label
486
461
  }),
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
462
+ ...Object.fromEntries(
463
+ thead.map((eachHeadEl) => [eachHeadEl.name, subRowElements])
464
+ ),
465
+ 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)))
489
466
  };
490
467
  });
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
- };
468
+ if (!columns.some((col) => col.dataIndex === "actions")) {
469
+ columns.push({
470
+ title: "Actions",
471
+ dataIndex: "actions",
472
+ key: "actions"
473
+ });
474
+ }
510
475
  return /* @__PURE__ */ import_react13.default.createElement(
511
476
  import_antd11.Table,
512
477
  {
513
478
  columns,
514
479
  dataSource,
515
480
  pagination: false,
516
- bordered: true,
517
- expandable: { expandedRowRender }
481
+ bordered: true
518
482
  }
519
483
  );
520
484
  };
package/dist/index.mjs CHANGED
@@ -383,32 +383,11 @@ var AddMoreTable = (props) => {
383
383
  });
384
384
  });
385
385
  };
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
- }
386
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
387
+ title: eachHeadEl.label,
388
+ dataIndex: eachHeadEl.name,
389
+ key: eachHeadEl.id
390
+ })) : [];
412
391
  const renderInputElement = (element) => {
413
392
  const { element: type, label } = element;
414
393
  if (type === "single-select") {
@@ -420,16 +399,12 @@ var AddMoreTable = (props) => {
420
399
  }
421
400
  };
422
401
  const dataSource = rows.map((eachRow, index) => {
423
- const subRow = eachRow.variable_data.map((variable, subIndex) => ({
424
- key: `${eachRow.id}-${subIndex}`,
425
- ...Object.fromEntries(Object.entries(variable).map(([key, value]) => {
426
- if (key === "icons") {
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)))];
428
- } else {
429
- return [key, renderInputElement(value)];
430
- }
431
- }))
432
- }));
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)))));
433
408
  return {
434
409
  key: eachRow.id,
435
410
  index: index + 1,
@@ -437,37 +412,26 @@ var AddMoreTable = (props) => {
437
412
  element: eachRow.element,
438
413
  label: eachRow.label
439
414
  }),
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
415
+ ...Object.fromEntries(
416
+ thead.map((eachHeadEl) => [eachHeadEl.name, subRowElements])
417
+ ),
418
+ 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)))
442
419
  };
443
420
  });
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
- };
421
+ if (!columns.some((col) => col.dataIndex === "actions")) {
422
+ columns.push({
423
+ title: "Actions",
424
+ dataIndex: "actions",
425
+ key: "actions"
426
+ });
427
+ }
463
428
  return /* @__PURE__ */ React12.createElement(
464
429
  Table,
465
430
  {
466
431
  columns,
467
432
  dataSource,
468
433
  pagination: false,
469
- bordered: true,
470
- expandable: { expandedRowRender }
434
+ bordered: true
471
435
  }
472
436
  );
473
437
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta71",
3
+ "version": "0.0.11-Beta72",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",