@apexcura/ui-components 0.0.11-Beta7 → 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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +135 -23
- package/dist/index.mjs +136 -24
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -361,22 +361,103 @@ var ButtonElement = () => /* @__PURE__ */ import_react12.default.createElement(i
|
|
|
361
361
|
// src/Components/AddMoreTable.tsx
|
|
362
362
|
var import_react13 = __toESM(require("react"));
|
|
363
363
|
var import_antd11 = require("antd");
|
|
364
|
+
var import_icons2 = require("@ant-design/icons");
|
|
364
365
|
var AddMoreTable = (props) => {
|
|
365
|
-
const { thead, tbody } = props;
|
|
366
|
-
console.log("-----------tbody", tbody);
|
|
367
|
-
console.log("..........thead", thead);
|
|
366
|
+
const { thead = [], tbody } = props;
|
|
368
367
|
const [tableData, setTableData] = (0, import_react13.useState)({});
|
|
368
|
+
const [rows, setRows] = (0, import_react13.useState)(tbody || []);
|
|
369
369
|
const onHandleChange = (name, value) => {
|
|
370
370
|
setTableData((prev) => ({ ...prev, [name]: value }));
|
|
371
371
|
console.log(tableData);
|
|
372
372
|
};
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
373
|
+
const onHandleRows = () => {
|
|
374
|
+
const lastRow = rows[rows.length - 1];
|
|
375
|
+
const newId = lastRow ? lastRow.id + 1 : 1;
|
|
376
|
+
let newRow = {
|
|
377
|
+
id: newId,
|
|
378
|
+
variable_data: [
|
|
379
|
+
{
|
|
380
|
+
id: 1,
|
|
381
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
382
|
+
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
383
|
+
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
384
|
+
When: { label: "When", element: "textarea", type: "text" },
|
|
385
|
+
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
386
|
+
Instructions: { label: "Instructions", element: "textarea", type: "text" },
|
|
387
|
+
icons: { delete: "delete", add: "plus" }
|
|
388
|
+
}
|
|
389
|
+
]
|
|
390
|
+
};
|
|
391
|
+
setRows((prevData) => [...prevData, newRow]);
|
|
392
|
+
};
|
|
393
|
+
const onHandleDelete = (id) => {
|
|
394
|
+
setRows((prevRows) => prevRows.filter((row) => row.id !== id));
|
|
395
|
+
};
|
|
396
|
+
const onHandleSubRowsAdd = (rowIndex) => {
|
|
397
|
+
setRows((prevRows) => {
|
|
398
|
+
return prevRows.map((row, index) => {
|
|
399
|
+
if (index === rowIndex) {
|
|
400
|
+
const newSubRow = {
|
|
401
|
+
id: row.variable_data.length + 1,
|
|
402
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
403
|
+
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
404
|
+
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
405
|
+
When: { label: "When", element: "textarea", type: "text" },
|
|
406
|
+
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
407
|
+
Instructions: { label: "Instructions", element: "textarea", type: "text" },
|
|
408
|
+
icons: { delete: "delete", add: "plus" }
|
|
409
|
+
};
|
|
410
|
+
return {
|
|
411
|
+
...row,
|
|
412
|
+
variable_data: [...row.variable_data, newSubRow]
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
return row;
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
const onHandleSubRowsDelete = (rowIndex, subIndex) => {
|
|
420
|
+
setRows((prevRows) => {
|
|
421
|
+
return prevRows.map((row, index) => {
|
|
422
|
+
if (index === rowIndex) {
|
|
423
|
+
const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
|
|
424
|
+
return {
|
|
425
|
+
...row,
|
|
426
|
+
variable_data: updatedVariableData
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
return row;
|
|
430
|
+
});
|
|
431
|
+
});
|
|
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
|
+
}
|
|
378
459
|
const renderInputElement = (element) => {
|
|
379
|
-
const { type, label } = element;
|
|
460
|
+
const { element: type, label } = element;
|
|
380
461
|
if (type === "single-select") {
|
|
381
462
|
return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
|
|
382
463
|
} else if (type === "textarea") {
|
|
@@ -385,26 +466,57 @@ var AddMoreTable = (props) => {
|
|
|
385
466
|
return null;
|
|
386
467
|
}
|
|
387
468
|
};
|
|
388
|
-
const dataSource =
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
469
|
+
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
|
+
}));
|
|
394
480
|
return {
|
|
395
|
-
key:
|
|
396
|
-
|
|
397
|
-
|
|
481
|
+
key: eachRow.id,
|
|
482
|
+
index: index + 1,
|
|
483
|
+
medicine: renderInputElement({
|
|
484
|
+
element: eachRow.element,
|
|
485
|
+
label: eachRow.label
|
|
486
|
+
}),
|
|
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
|
|
398
489
|
};
|
|
399
|
-
})
|
|
400
|
-
|
|
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
|
+
};
|
|
510
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
401
511
|
import_antd11.Table,
|
|
402
512
|
{
|
|
403
513
|
columns,
|
|
404
|
-
|
|
405
|
-
|
|
514
|
+
dataSource,
|
|
515
|
+
pagination: false,
|
|
516
|
+
bordered: true,
|
|
517
|
+
expandable: { expandedRowRender }
|
|
406
518
|
}
|
|
407
|
-
)
|
|
519
|
+
);
|
|
408
520
|
};
|
|
409
521
|
// Annotate the CommonJS export names for ESM import in node:
|
|
410
522
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -313,23 +313,104 @@ var ButtonElement = () => /* @__PURE__ */ React11.createElement(Flex2, { gap: "s
|
|
|
313
313
|
|
|
314
314
|
// src/Components/AddMoreTable.tsx
|
|
315
315
|
import React12, { useState as useState3 } from "react";
|
|
316
|
-
import { Table } from "antd";
|
|
316
|
+
import { Table, Button as Button3 } from "antd";
|
|
317
|
+
import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
|
|
317
318
|
var AddMoreTable = (props) => {
|
|
318
|
-
const { thead, tbody } = props;
|
|
319
|
-
console.log("-----------tbody", tbody);
|
|
320
|
-
console.log("..........thead", thead);
|
|
319
|
+
const { thead = [], tbody } = props;
|
|
321
320
|
const [tableData, setTableData] = useState3({});
|
|
321
|
+
const [rows, setRows] = useState3(tbody || []);
|
|
322
322
|
const onHandleChange = (name, value) => {
|
|
323
323
|
setTableData((prev) => ({ ...prev, [name]: value }));
|
|
324
324
|
console.log(tableData);
|
|
325
325
|
};
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
326
|
+
const onHandleRows = () => {
|
|
327
|
+
const lastRow = rows[rows.length - 1];
|
|
328
|
+
const newId = lastRow ? lastRow.id + 1 : 1;
|
|
329
|
+
let newRow = {
|
|
330
|
+
id: newId,
|
|
331
|
+
variable_data: [
|
|
332
|
+
{
|
|
333
|
+
id: 1,
|
|
334
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
335
|
+
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
336
|
+
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
337
|
+
When: { label: "When", element: "textarea", type: "text" },
|
|
338
|
+
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
339
|
+
Instructions: { label: "Instructions", element: "textarea", type: "text" },
|
|
340
|
+
icons: { delete: "delete", add: "plus" }
|
|
341
|
+
}
|
|
342
|
+
]
|
|
343
|
+
};
|
|
344
|
+
setRows((prevData) => [...prevData, newRow]);
|
|
345
|
+
};
|
|
346
|
+
const onHandleDelete = (id) => {
|
|
347
|
+
setRows((prevRows) => prevRows.filter((row) => row.id !== id));
|
|
348
|
+
};
|
|
349
|
+
const onHandleSubRowsAdd = (rowIndex) => {
|
|
350
|
+
setRows((prevRows) => {
|
|
351
|
+
return prevRows.map((row, index) => {
|
|
352
|
+
if (index === rowIndex) {
|
|
353
|
+
const newSubRow = {
|
|
354
|
+
id: row.variable_data.length + 1,
|
|
355
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
356
|
+
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
357
|
+
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
358
|
+
When: { label: "When", element: "textarea", type: "text" },
|
|
359
|
+
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
360
|
+
Instructions: { label: "Instructions", element: "textarea", type: "text" },
|
|
361
|
+
icons: { delete: "delete", add: "plus" }
|
|
362
|
+
};
|
|
363
|
+
return {
|
|
364
|
+
...row,
|
|
365
|
+
variable_data: [...row.variable_data, newSubRow]
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
return row;
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
const onHandleSubRowsDelete = (rowIndex, subIndex) => {
|
|
373
|
+
setRows((prevRows) => {
|
|
374
|
+
return prevRows.map((row, index) => {
|
|
375
|
+
if (index === rowIndex) {
|
|
376
|
+
const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
|
|
377
|
+
return {
|
|
378
|
+
...row,
|
|
379
|
+
variable_data: updatedVariableData
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
return row;
|
|
383
|
+
});
|
|
384
|
+
});
|
|
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
|
+
}
|
|
331
412
|
const renderInputElement = (element) => {
|
|
332
|
-
const { type, label } = element;
|
|
413
|
+
const { element: type, label } = element;
|
|
333
414
|
if (type === "single-select") {
|
|
334
415
|
return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
|
|
335
416
|
} else if (type === "textarea") {
|
|
@@ -338,26 +419,57 @@ var AddMoreTable = (props) => {
|
|
|
338
419
|
return null;
|
|
339
420
|
}
|
|
340
421
|
};
|
|
341
|
-
const dataSource =
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
422
|
+
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
|
+
}));
|
|
347
433
|
return {
|
|
348
|
-
key:
|
|
349
|
-
|
|
350
|
-
|
|
434
|
+
key: eachRow.id,
|
|
435
|
+
index: index + 1,
|
|
436
|
+
medicine: renderInputElement({
|
|
437
|
+
element: eachRow.element,
|
|
438
|
+
label: eachRow.label
|
|
439
|
+
}),
|
|
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
|
|
351
442
|
};
|
|
352
|
-
})
|
|
353
|
-
|
|
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
|
+
};
|
|
463
|
+
return /* @__PURE__ */ React12.createElement(
|
|
354
464
|
Table,
|
|
355
465
|
{
|
|
356
466
|
columns,
|
|
357
|
-
|
|
358
|
-
|
|
467
|
+
dataSource,
|
|
468
|
+
pagination: false,
|
|
469
|
+
bordered: true,
|
|
470
|
+
expandable: { expandedRowRender }
|
|
359
471
|
}
|
|
360
|
-
)
|
|
472
|
+
);
|
|
361
473
|
};
|
|
362
474
|
export {
|
|
363
475
|
AddMoreTable,
|