@apexcura/ui-components 0.0.11-Beta41 → 0.0.11-Beta43
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 +34 -23
- package/dist/index.mjs +35 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -411,6 +411,20 @@ var AddMoreTable = (props) => {
|
|
|
411
411
|
});
|
|
412
412
|
});
|
|
413
413
|
};
|
|
414
|
+
const onHandleSubRowsDelete = (rowIndex, subIndex) => {
|
|
415
|
+
setRows((prevRows) => {
|
|
416
|
+
return prevRows.map((row, index) => {
|
|
417
|
+
if (index === rowIndex) {
|
|
418
|
+
const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
|
|
419
|
+
return {
|
|
420
|
+
...row,
|
|
421
|
+
variable_data: updatedVariableData
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
return row;
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
};
|
|
414
428
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
415
429
|
title: eachHeadEl.label,
|
|
416
430
|
dataIndex: eachHeadEl.name,
|
|
@@ -426,33 +440,29 @@ var AddMoreTable = (props) => {
|
|
|
426
440
|
return null;
|
|
427
441
|
}
|
|
428
442
|
};
|
|
429
|
-
const dataSource = rows.
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
443
|
+
const dataSource = rows.flatMap((eachRow, index) => {
|
|
444
|
+
const rowData = [];
|
|
445
|
+
const mainRow = {
|
|
446
|
+
key: index.toString(),
|
|
447
|
+
"#": index + 1,
|
|
448
|
+
...eachRow,
|
|
449
|
+
actions: /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, 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)))
|
|
450
|
+
};
|
|
451
|
+
rowData.push(mainRow);
|
|
434
452
|
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
435
|
-
eachRow.variable_data.forEach((variable) => {
|
|
453
|
+
eachRow.variable_data.forEach((variable, subIndex) => {
|
|
454
|
+
const subRowElements = {};
|
|
436
455
|
Object.entries(variable).forEach(([key, value]) => {
|
|
437
456
|
if (key === "icons" && value) {
|
|
438
|
-
{
|
|
439
|
-
eachRow.variable_data.map((variable2, subIndex) => {
|
|
440
|
-
rowElements["sub rows"] = /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, eachRow.variable_data.length > 1 && /* @__PURE__ */ import_react13.default.createElement("button", null, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onHandleSubRowsAdd(index) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
|
|
441
|
-
});
|
|
442
|
-
}
|
|
457
|
+
subRowElements["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)));
|
|
443
458
|
} else if (value && value.element && value.label) {
|
|
444
|
-
|
|
459
|
+
subRowElements[value.label] = renderInputElement(value);
|
|
445
460
|
}
|
|
446
461
|
});
|
|
462
|
+
rowData.push(subRowElements);
|
|
447
463
|
});
|
|
448
464
|
}
|
|
449
|
-
return
|
|
450
|
-
key: index.toString(),
|
|
451
|
-
"#": index + 1,
|
|
452
|
-
...eachRow,
|
|
453
|
-
...rowElements,
|
|
454
|
-
actions: /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ import_react13.default.createElement("button", { onClick: onHandleRows }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)))
|
|
455
|
-
};
|
|
465
|
+
return rowData;
|
|
456
466
|
});
|
|
457
467
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|
|
458
468
|
columns.push({
|
|
@@ -461,14 +471,15 @@ var AddMoreTable = (props) => {
|
|
|
461
471
|
key: "actions"
|
|
462
472
|
});
|
|
463
473
|
}
|
|
464
|
-
return /* @__PURE__ */ import_react13.default.createElement(
|
|
474
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
465
475
|
import_antd11.Table,
|
|
466
476
|
{
|
|
467
477
|
columns,
|
|
468
|
-
|
|
469
|
-
|
|
478
|
+
dataSource,
|
|
479
|
+
pagination: false,
|
|
480
|
+
bordered: true
|
|
470
481
|
}
|
|
471
|
-
)
|
|
482
|
+
);
|
|
472
483
|
};
|
|
473
484
|
// Annotate the CommonJS export names for ESM import in node:
|
|
474
485
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -313,7 +313,7 @@ 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
317
|
import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
|
|
318
318
|
var AddMoreTable = (props) => {
|
|
319
319
|
const { thead, tbody } = props;
|
|
@@ -364,6 +364,20 @@ var AddMoreTable = (props) => {
|
|
|
364
364
|
});
|
|
365
365
|
});
|
|
366
366
|
};
|
|
367
|
+
const onHandleSubRowsDelete = (rowIndex, subIndex) => {
|
|
368
|
+
setRows((prevRows) => {
|
|
369
|
+
return prevRows.map((row, index) => {
|
|
370
|
+
if (index === rowIndex) {
|
|
371
|
+
const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
|
|
372
|
+
return {
|
|
373
|
+
...row,
|
|
374
|
+
variable_data: updatedVariableData
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
return row;
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
};
|
|
367
381
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
368
382
|
title: eachHeadEl.label,
|
|
369
383
|
dataIndex: eachHeadEl.name,
|
|
@@ -379,33 +393,29 @@ var AddMoreTable = (props) => {
|
|
|
379
393
|
return null;
|
|
380
394
|
}
|
|
381
395
|
};
|
|
382
|
-
const dataSource = rows.
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
396
|
+
const dataSource = rows.flatMap((eachRow, index) => {
|
|
397
|
+
const rowData = [];
|
|
398
|
+
const mainRow = {
|
|
399
|
+
key: index.toString(),
|
|
400
|
+
"#": index + 1,
|
|
401
|
+
...eachRow,
|
|
402
|
+
actions: /* @__PURE__ */ React12.createElement(React12.Fragment, 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)))
|
|
403
|
+
};
|
|
404
|
+
rowData.push(mainRow);
|
|
387
405
|
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
388
|
-
eachRow.variable_data.forEach((variable) => {
|
|
406
|
+
eachRow.variable_data.forEach((variable, subIndex) => {
|
|
407
|
+
const subRowElements = {};
|
|
389
408
|
Object.entries(variable).forEach(([key, value]) => {
|
|
390
409
|
if (key === "icons" && value) {
|
|
391
|
-
{
|
|
392
|
-
eachRow.variable_data.map((variable2, subIndex) => {
|
|
393
|
-
rowElements["sub rows"] = /* @__PURE__ */ React12.createElement(React12.Fragment, null, eachRow.variable_data.length > 1 && /* @__PURE__ */ React12.createElement("button", null, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleSubRowsAdd(index) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
|
|
394
|
-
});
|
|
395
|
-
}
|
|
410
|
+
subRowElements["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)));
|
|
396
411
|
} else if (value && value.element && value.label) {
|
|
397
|
-
|
|
412
|
+
subRowElements[value.label] = renderInputElement(value);
|
|
398
413
|
}
|
|
399
414
|
});
|
|
415
|
+
rowData.push(subRowElements);
|
|
400
416
|
});
|
|
401
417
|
}
|
|
402
|
-
return
|
|
403
|
-
key: index.toString(),
|
|
404
|
-
"#": index + 1,
|
|
405
|
-
...eachRow,
|
|
406
|
-
...rowElements,
|
|
407
|
-
actions: /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ React12.createElement("button", { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)))
|
|
408
|
-
};
|
|
418
|
+
return rowData;
|
|
409
419
|
});
|
|
410
420
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|
|
411
421
|
columns.push({
|
|
@@ -414,14 +424,15 @@ var AddMoreTable = (props) => {
|
|
|
414
424
|
key: "actions"
|
|
415
425
|
});
|
|
416
426
|
}
|
|
417
|
-
return /* @__PURE__ */ React12.createElement(
|
|
427
|
+
return /* @__PURE__ */ React12.createElement(
|
|
418
428
|
Table,
|
|
419
429
|
{
|
|
420
430
|
columns,
|
|
421
|
-
|
|
422
|
-
|
|
431
|
+
dataSource,
|
|
432
|
+
pagination: false,
|
|
433
|
+
bordered: true
|
|
423
434
|
}
|
|
424
|
-
)
|
|
435
|
+
);
|
|
425
436
|
};
|
|
426
437
|
export {
|
|
427
438
|
AddMoreTable,
|