@apexcura/ui-components 0.0.11-Beta65 → 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 +24 -41
- package/dist/index.mjs +24 -41
- package/package.json +1 -1
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,28 +374,24 @@ 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
|
{
|
|
384
380
|
id: 1,
|
|
385
|
-
Route: { label: "Route", element: "
|
|
381
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
386
382
|
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
387
383
|
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
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: "
|
|
387
|
+
icons: { delete: "delete", add: "plus" }
|
|
392
388
|
}
|
|
393
389
|
]
|
|
394
390
|
};
|
|
395
391
|
setRows((prevData) => [...prevData, newRow]);
|
|
396
392
|
};
|
|
397
|
-
const onHandleDelete = (
|
|
398
|
-
|
|
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: "
|
|
408
|
+
icons: { delete: "delete", add: "plus" }
|
|
416
409
|
};
|
|
417
410
|
return {
|
|
418
411
|
...row,
|
|
@@ -452,39 +445,29 @@ var AddMoreTable = (props) => {
|
|
|
452
445
|
return null;
|
|
453
446
|
}
|
|
454
447
|
};
|
|
455
|
-
const dataSource = rows.
|
|
456
|
-
const rowData =
|
|
457
|
-
|
|
458
|
-
key: index.toString(),
|
|
448
|
+
const dataSource = rows.map((eachRow, index) => {
|
|
449
|
+
const rowData = {
|
|
450
|
+
key: eachRow.id.toString(),
|
|
459
451
|
"#": index + 1,
|
|
460
|
-
|
|
461
|
-
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)))
|
|
462
|
-
};
|
|
463
|
-
const subRowElements = [];
|
|
464
|
-
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
465
|
-
eachRow.variable_data.forEach((variable, subIndex) => {
|
|
466
|
-
const subRowElement = {};
|
|
467
|
-
Object.entries(variable).forEach(([key, value]) => {
|
|
468
|
-
if (key === "icons" && value) {
|
|
469
|
-
subRowElement["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)));
|
|
470
|
-
} else if (value && value.element && value.label) {
|
|
471
|
-
subRowElement[value.label] = renderInputElement(value);
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
subRowElements.push(subRowElement);
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
rowData.push({
|
|
478
|
-
...mainRow,
|
|
479
|
-
"Medicine": renderInputElement({
|
|
452
|
+
Medicine: renderInputElement({
|
|
480
453
|
element: eachRow.element,
|
|
481
454
|
label: eachRow.label
|
|
482
455
|
}),
|
|
483
|
-
"
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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
|
+
if (key === "icons") {
|
|
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)];
|
|
465
|
+
}
|
|
466
|
+
}))
|
|
467
|
+
}));
|
|
468
|
+
return [rowData, ...subRows];
|
|
469
|
+
}).flat();
|
|
470
|
+
if (!columns.some((col) => col.dataIndex === "actions")) {
|
|
488
471
|
columns.push({
|
|
489
472
|
title: "Actions",
|
|
490
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,28 +327,24 @@ 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
|
{
|
|
337
333
|
id: 1,
|
|
338
|
-
Route: { label: "Route", element: "
|
|
334
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
339
335
|
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
340
336
|
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
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: "
|
|
340
|
+
icons: { delete: "delete", add: "plus" }
|
|
345
341
|
}
|
|
346
342
|
]
|
|
347
343
|
};
|
|
348
344
|
setRows((prevData) => [...prevData, newRow]);
|
|
349
345
|
};
|
|
350
|
-
const onHandleDelete = (
|
|
351
|
-
|
|
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: "
|
|
361
|
+
icons: { delete: "delete", add: "plus" }
|
|
369
362
|
};
|
|
370
363
|
return {
|
|
371
364
|
...row,
|
|
@@ -405,39 +398,29 @@ var AddMoreTable = (props) => {
|
|
|
405
398
|
return null;
|
|
406
399
|
}
|
|
407
400
|
};
|
|
408
|
-
const dataSource = rows.
|
|
409
|
-
const rowData =
|
|
410
|
-
|
|
411
|
-
key: index.toString(),
|
|
401
|
+
const dataSource = rows.map((eachRow, index) => {
|
|
402
|
+
const rowData = {
|
|
403
|
+
key: eachRow.id.toString(),
|
|
412
404
|
"#": index + 1,
|
|
413
|
-
|
|
414
|
-
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)))
|
|
415
|
-
};
|
|
416
|
-
const subRowElements = [];
|
|
417
|
-
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
418
|
-
eachRow.variable_data.forEach((variable, subIndex) => {
|
|
419
|
-
const subRowElement = {};
|
|
420
|
-
Object.entries(variable).forEach(([key, value]) => {
|
|
421
|
-
if (key === "icons" && value) {
|
|
422
|
-
subRowElement["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)));
|
|
423
|
-
} else if (value && value.element && value.label) {
|
|
424
|
-
subRowElement[value.label] = renderInputElement(value);
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
subRowElements.push(subRowElement);
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
rowData.push({
|
|
431
|
-
...mainRow,
|
|
432
|
-
"Medicine": renderInputElement({
|
|
405
|
+
Medicine: renderInputElement({
|
|
433
406
|
element: eachRow.element,
|
|
434
407
|
label: eachRow.label
|
|
435
408
|
}),
|
|
436
|
-
"
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
+
if (key === "icons") {
|
|
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)];
|
|
418
|
+
}
|
|
419
|
+
}))
|
|
420
|
+
}));
|
|
421
|
+
return [rowData, ...subRows];
|
|
422
|
+
}).flat();
|
|
423
|
+
if (!columns.some((col) => col.dataIndex === "actions")) {
|
|
441
424
|
columns.push({
|
|
442
425
|
title: "Actions",
|
|
443
426
|
dataIndex: "actions",
|