@apexcura/ui-components 0.0.11-Beta63 → 0.0.11-Beta66

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
@@ -366,9 +366,6 @@ var AddMoreTable = (props) => {
366
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
- function isColumnType(column) {
370
- return column.dataIndex !== void 0;
371
- }
372
369
  const onHandleChange = (name, value) => {
373
370
  setTableData((prev) => ({ ...prev, [name]: value }));
374
371
  console.log(tableData);
@@ -377,7 +374,6 @@ var AddMoreTable = (props) => {
377
374
  const lastRow = rows[rows.length - 1];
378
375
  const newId = lastRow ? lastRow.id + 1 : 1;
379
376
  let newRow = {
380
- ...lastRow,
381
377
  id: newId,
382
378
  variable_data: [
383
379
  {
@@ -388,17 +384,14 @@ var AddMoreTable = (props) => {
388
384
  When: { label: "When", element: "textarea", type: "text" },
389
385
  Duration: { label: "Duration", element: "textarea", type: "text" },
390
386
  Instructions: { label: "Instructions", element: "textarea", type: "text" },
391
- icons: { delete: "plusOutlined", add: "plusOutlined" }
387
+ icons: { delete: "delete", add: "plus" }
392
388
  }
393
389
  ]
394
390
  };
395
391
  setRows((prevData) => [...prevData, newRow]);
396
392
  };
397
- const onHandleDelete = (index) => {
398
- if (rows.length > 1) {
399
- const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
400
- setRows(remainingRows);
401
- }
393
+ const onHandleDelete = (id) => {
394
+ setRows((prevRows) => prevRows.filter((row) => row.id !== id));
402
395
  };
403
396
  const onHandleSubRowsAdd = (rowIndex) => {
404
397
  setRows((prevRows) => {
@@ -412,7 +405,7 @@ var AddMoreTable = (props) => {
412
405
  When: { label: "When", element: "textarea", type: "text" },
413
406
  Duration: { label: "Duration", element: "textarea", type: "text" },
414
407
  Instructions: { label: "Instructions", element: "textarea", type: "text" },
415
- icons: { delete: "plusOutlined", add: "plusOutlined" }
408
+ icons: { delete: "delete", add: "plus" }
416
409
  };
417
410
  return {
418
411
  ...row,
@@ -445,35 +438,36 @@ var AddMoreTable = (props) => {
445
438
  const renderInputElement = (element) => {
446
439
  const { element: type, label } = element;
447
440
  if (type === "single-select") {
448
- return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { key: label, onChange: (value) => onHandleChange(label, value) });
441
+ return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
449
442
  } else if (type === "textarea") {
450
- return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { key: label, onChange: (value) => onHandleChange(label, value) });
443
+ return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
451
444
  } else {
452
445
  return null;
453
446
  }
454
447
  };
455
448
  const dataSource = rows.map((eachRow, index) => {
456
- const mainRow = {
449
+ const rowData = {
457
450
  key: eachRow.id.toString(),
458
451
  "#": 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]) => {
452
+ Medicine: renderInputElement({
453
+ element: eachRow.element,
454
+ label: eachRow.label
455
+ }),
456
+ 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)))
457
+ };
458
+ const subRows = eachRow.variable_data.map((variable, subIndex) => ({
459
+ key: `${eachRow.id}-${subIndex}`,
460
+ ...Object.fromEntries(Object.entries(variable).map(([key, value]) => {
461
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)));
462
+ 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)))];
463
+ } else {
464
+ return [key, renderInputElement(value)];
463
465
  }
464
- if (value && value.element && value.label) {
465
- return renderInputElement(value);
466
- }
467
- return null;
468
- })))
469
- };
470
- return {
471
- ...mainRow,
472
- ...eachRow,
473
- subRows: /* @__PURE__ */ import_react13.default.createElement("div", null, mainRow.subRows)
474
- };
475
- });
476
- if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
466
+ }))
467
+ }));
468
+ return [rowData, ...subRows];
469
+ }).flat();
470
+ if (!columns.some((col) => col.dataIndex === "actions")) {
477
471
  columns.push({
478
472
  title: "Actions",
479
473
  dataIndex: "actions",
package/dist/index.mjs CHANGED
@@ -319,9 +319,6 @@ var AddMoreTable = (props) => {
319
319
  const { thead, tbody } = props;
320
320
  const [tableData, setTableData] = useState3({});
321
321
  const [rows, setRows] = useState3(tbody || []);
322
- function isColumnType(column) {
323
- return column.dataIndex !== void 0;
324
- }
325
322
  const onHandleChange = (name, value) => {
326
323
  setTableData((prev) => ({ ...prev, [name]: value }));
327
324
  console.log(tableData);
@@ -330,7 +327,6 @@ var AddMoreTable = (props) => {
330
327
  const lastRow = rows[rows.length - 1];
331
328
  const newId = lastRow ? lastRow.id + 1 : 1;
332
329
  let newRow = {
333
- ...lastRow,
334
330
  id: newId,
335
331
  variable_data: [
336
332
  {
@@ -341,17 +337,14 @@ var AddMoreTable = (props) => {
341
337
  When: { label: "When", element: "textarea", type: "text" },
342
338
  Duration: { label: "Duration", element: "textarea", type: "text" },
343
339
  Instructions: { label: "Instructions", element: "textarea", type: "text" },
344
- icons: { delete: "plusOutlined", add: "plusOutlined" }
340
+ icons: { delete: "delete", add: "plus" }
345
341
  }
346
342
  ]
347
343
  };
348
344
  setRows((prevData) => [...prevData, newRow]);
349
345
  };
350
- const onHandleDelete = (index) => {
351
- if (rows.length > 1) {
352
- const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
353
- setRows(remainingRows);
354
- }
346
+ const onHandleDelete = (id) => {
347
+ setRows((prevRows) => prevRows.filter((row) => row.id !== id));
355
348
  };
356
349
  const onHandleSubRowsAdd = (rowIndex) => {
357
350
  setRows((prevRows) => {
@@ -365,7 +358,7 @@ var AddMoreTable = (props) => {
365
358
  When: { label: "When", element: "textarea", type: "text" },
366
359
  Duration: { label: "Duration", element: "textarea", type: "text" },
367
360
  Instructions: { label: "Instructions", element: "textarea", type: "text" },
368
- icons: { delete: "plusOutlined", add: "plusOutlined" }
361
+ icons: { delete: "delete", add: "plus" }
369
362
  };
370
363
  return {
371
364
  ...row,
@@ -398,35 +391,36 @@ var AddMoreTable = (props) => {
398
391
  const renderInputElement = (element) => {
399
392
  const { element: type, label } = element;
400
393
  if (type === "single-select") {
401
- return /* @__PURE__ */ React12.createElement(SingleSelectElement, { key: label, onChange: (value) => onHandleChange(label, value) });
394
+ return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
402
395
  } else if (type === "textarea") {
403
- return /* @__PURE__ */ React12.createElement(TextareaElement, { key: label, onChange: (value) => onHandleChange(label, value) });
396
+ return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
404
397
  } else {
405
398
  return null;
406
399
  }
407
400
  };
408
401
  const dataSource = rows.map((eachRow, index) => {
409
- const mainRow = {
402
+ const rowData = {
410
403
  key: eachRow.id.toString(),
411
404
  "#": 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]) => {
405
+ Medicine: renderInputElement({
406
+ element: eachRow.element,
407
+ label: eachRow.label
408
+ }),
409
+ 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)))
410
+ };
411
+ const subRows = eachRow.variable_data.map((variable, subIndex) => ({
412
+ key: `${eachRow.id}-${subIndex}`,
413
+ ...Object.fromEntries(Object.entries(variable).map(([key, value]) => {
414
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)));
415
+ 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)))];
416
+ } else {
417
+ return [key, renderInputElement(value)];
416
418
  }
417
- if (value && value.element && value.label) {
418
- return renderInputElement(value);
419
- }
420
- return null;
421
- })))
422
- };
423
- return {
424
- ...mainRow,
425
- ...eachRow,
426
- subRows: /* @__PURE__ */ React12.createElement("div", null, mainRow.subRows)
427
- };
428
- });
429
- if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
419
+ }))
420
+ }));
421
+ return [rowData, ...subRows];
422
+ }).flat();
423
+ if (!columns.some((col) => col.dataIndex === "actions")) {
430
424
  columns.push({
431
425
  title: "Actions",
432
426
  dataIndex: "actions",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta63",
3
+ "version": "0.0.11-Beta66",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",