@apexcura/ui-components 0.0.11-Beta13 → 0.0.11-Beta15
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 +47 -10
- package/dist/index.mjs +47 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -361,14 +361,31 @@ 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
366
|
const { thead, tbody } = props;
|
|
366
367
|
const [tableData, setTableData] = (0, import_react13.useState)({});
|
|
367
|
-
|
|
368
|
+
const [rows, setRows] = (0, import_react13.useState)(tbody || []);
|
|
369
|
+
function isColumnType(column) {
|
|
370
|
+
return column.dataIndex !== void 0;
|
|
371
|
+
}
|
|
368
372
|
const onHandleChange = (name, value) => {
|
|
369
373
|
setTableData((prev) => ({ ...prev, [name]: value }));
|
|
370
374
|
console.log(tableData);
|
|
371
375
|
};
|
|
376
|
+
const onHandleRows = () => {
|
|
377
|
+
const lastRow = rows[rows.length - 1];
|
|
378
|
+
const newId = lastRow ? lastRow.id + 1 : lastRow.id;
|
|
379
|
+
const newRow = {
|
|
380
|
+
...lastRow,
|
|
381
|
+
id: newId
|
|
382
|
+
};
|
|
383
|
+
setRows((prevData) => [...prevData, newRow]);
|
|
384
|
+
};
|
|
385
|
+
const onHandleDelete = (index) => {
|
|
386
|
+
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
387
|
+
setRows(remainingRows);
|
|
388
|
+
};
|
|
372
389
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
373
390
|
title: eachHeadEl.label,
|
|
374
391
|
dataIndex: eachHeadEl.name,
|
|
@@ -385,20 +402,40 @@ var AddMoreTable = (props) => {
|
|
|
385
402
|
return null;
|
|
386
403
|
}
|
|
387
404
|
};
|
|
388
|
-
const dataSource =
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
405
|
+
const dataSource = rows.map((eachRow, index) => {
|
|
406
|
+
console.log("eachRow=======", eachRow);
|
|
407
|
+
const rowElements = {};
|
|
408
|
+
if (eachRow.element && eachRow.label) {
|
|
409
|
+
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
410
|
+
}
|
|
411
|
+
const variableData = eachRow.variable_data && Array.isArray(eachRow.variable_data) ? eachRow.variable_data.reduce((acc, curr) => {
|
|
412
|
+
for (let i = 0; i < curr.length; i++) {
|
|
413
|
+
Object.keys(curr[i].forEach((key) => {
|
|
414
|
+
if (curr[i][key] && curr[i][key].element) {
|
|
415
|
+
rowElements[eachRow.label] = renderInputElement(curr[i][key] && curr[i][key].element);
|
|
416
|
+
console.log(curr[i][key] && curr[i][key].element);
|
|
417
|
+
}
|
|
418
|
+
}));
|
|
419
|
+
}
|
|
393
420
|
return acc;
|
|
394
|
-
}, {});
|
|
421
|
+
}, {}) : {};
|
|
422
|
+
console.log("-----------");
|
|
395
423
|
return {
|
|
396
424
|
key: index.toString(),
|
|
425
|
+
"#": index + 1,
|
|
397
426
|
...eachRow,
|
|
398
|
-
...
|
|
427
|
+
...rowElements,
|
|
428
|
+
...variableData,
|
|
429
|
+
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)))
|
|
399
430
|
};
|
|
400
|
-
})
|
|
401
|
-
|
|
431
|
+
});
|
|
432
|
+
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|
|
433
|
+
columns.push({
|
|
434
|
+
title: "Actions",
|
|
435
|
+
dataIndex: "actions",
|
|
436
|
+
key: "actions"
|
|
437
|
+
});
|
|
438
|
+
}
|
|
402
439
|
return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
|
|
403
440
|
import_antd11.Table,
|
|
404
441
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -314,14 +314,31 @@ var ButtonElement = () => /* @__PURE__ */ React11.createElement(Flex2, { gap: "s
|
|
|
314
314
|
// src/Components/AddMoreTable.tsx
|
|
315
315
|
import React12, { useState as useState3 } from "react";
|
|
316
316
|
import { Table } from "antd";
|
|
317
|
+
import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
|
|
317
318
|
var AddMoreTable = (props) => {
|
|
318
319
|
const { thead, tbody } = props;
|
|
319
320
|
const [tableData, setTableData] = useState3({});
|
|
320
|
-
|
|
321
|
+
const [rows, setRows] = useState3(tbody || []);
|
|
322
|
+
function isColumnType(column) {
|
|
323
|
+
return column.dataIndex !== void 0;
|
|
324
|
+
}
|
|
321
325
|
const onHandleChange = (name, value) => {
|
|
322
326
|
setTableData((prev) => ({ ...prev, [name]: value }));
|
|
323
327
|
console.log(tableData);
|
|
324
328
|
};
|
|
329
|
+
const onHandleRows = () => {
|
|
330
|
+
const lastRow = rows[rows.length - 1];
|
|
331
|
+
const newId = lastRow ? lastRow.id + 1 : lastRow.id;
|
|
332
|
+
const newRow = {
|
|
333
|
+
...lastRow,
|
|
334
|
+
id: newId
|
|
335
|
+
};
|
|
336
|
+
setRows((prevData) => [...prevData, newRow]);
|
|
337
|
+
};
|
|
338
|
+
const onHandleDelete = (index) => {
|
|
339
|
+
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
340
|
+
setRows(remainingRows);
|
|
341
|
+
};
|
|
325
342
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
326
343
|
title: eachHeadEl.label,
|
|
327
344
|
dataIndex: eachHeadEl.name,
|
|
@@ -338,20 +355,40 @@ var AddMoreTable = (props) => {
|
|
|
338
355
|
return null;
|
|
339
356
|
}
|
|
340
357
|
};
|
|
341
|
-
const dataSource =
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
358
|
+
const dataSource = rows.map((eachRow, index) => {
|
|
359
|
+
console.log("eachRow=======", eachRow);
|
|
360
|
+
const rowElements = {};
|
|
361
|
+
if (eachRow.element && eachRow.label) {
|
|
362
|
+
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
363
|
+
}
|
|
364
|
+
const variableData = eachRow.variable_data && Array.isArray(eachRow.variable_data) ? eachRow.variable_data.reduce((acc, curr) => {
|
|
365
|
+
for (let i = 0; i < curr.length; i++) {
|
|
366
|
+
Object.keys(curr[i].forEach((key) => {
|
|
367
|
+
if (curr[i][key] && curr[i][key].element) {
|
|
368
|
+
rowElements[eachRow.label] = renderInputElement(curr[i][key] && curr[i][key].element);
|
|
369
|
+
console.log(curr[i][key] && curr[i][key].element);
|
|
370
|
+
}
|
|
371
|
+
}));
|
|
372
|
+
}
|
|
346
373
|
return acc;
|
|
347
|
-
}, {});
|
|
374
|
+
}, {}) : {};
|
|
375
|
+
console.log("-----------");
|
|
348
376
|
return {
|
|
349
377
|
key: index.toString(),
|
|
378
|
+
"#": index + 1,
|
|
350
379
|
...eachRow,
|
|
351
|
-
...
|
|
380
|
+
...rowElements,
|
|
381
|
+
...variableData,
|
|
382
|
+
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)))
|
|
352
383
|
};
|
|
353
|
-
})
|
|
354
|
-
|
|
384
|
+
});
|
|
385
|
+
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|
|
386
|
+
columns.push({
|
|
387
|
+
title: "Actions",
|
|
388
|
+
dataIndex: "actions",
|
|
389
|
+
key: "actions"
|
|
390
|
+
});
|
|
391
|
+
}
|
|
355
392
|
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
|
|
356
393
|
Table,
|
|
357
394
|
{
|