@apexcura/ui-components 0.0.11-Beta21 → 0.0.11-Beta22
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 +44 -21
- package/dist/index.mjs +44 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -375,17 +375,55 @@ var AddMoreTable = (props) => {
|
|
|
375
375
|
};
|
|
376
376
|
const onHandleRows = () => {
|
|
377
377
|
const lastRow = rows[rows.length - 1];
|
|
378
|
-
const newId = lastRow ? lastRow.id + 1 :
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
378
|
+
const newId = lastRow ? lastRow.id + 1 : 1;
|
|
379
|
+
let newRow;
|
|
380
|
+
if (lastRow && lastRow.variable_data && lastRow.variable_data.length > 0) {
|
|
381
|
+
const lastVariable = lastRow.variable_data[lastRow.variable_data.length - 1];
|
|
382
|
+
const newVariableId = lastVariable.id + 1;
|
|
383
|
+
newRow = {
|
|
384
|
+
...lastRow,
|
|
385
|
+
id: newId,
|
|
386
|
+
variable_data: [
|
|
387
|
+
...lastRow.variable_data,
|
|
388
|
+
{
|
|
389
|
+
id: newVariableId,
|
|
390
|
+
icon: {}
|
|
391
|
+
}
|
|
392
|
+
]
|
|
393
|
+
};
|
|
394
|
+
} else {
|
|
395
|
+
newRow = {
|
|
396
|
+
...lastRow,
|
|
397
|
+
id: newId
|
|
398
|
+
};
|
|
399
|
+
}
|
|
383
400
|
setRows((prevData) => [...prevData, newRow]);
|
|
384
401
|
};
|
|
385
402
|
const onHandleDelete = (index) => {
|
|
386
403
|
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
387
404
|
setRows(remainingRows);
|
|
388
405
|
};
|
|
406
|
+
const onAddVariableData = (rowIndex) => {
|
|
407
|
+
setRows((prevRows) => {
|
|
408
|
+
return prevRows.map((row, index) => {
|
|
409
|
+
if (index === rowIndex && row.variable_data && row.variable_data.length > 0) {
|
|
410
|
+
const lastVariable = row.variable_data[row.variable_data.length - 1];
|
|
411
|
+
const newVariableId = lastVariable.id + 1;
|
|
412
|
+
return {
|
|
413
|
+
...row,
|
|
414
|
+
variable_data: [
|
|
415
|
+
...row.variable_data,
|
|
416
|
+
{
|
|
417
|
+
id: newVariableId,
|
|
418
|
+
icon: {}
|
|
419
|
+
}
|
|
420
|
+
]
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
return row;
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
};
|
|
389
427
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
390
428
|
title: eachHeadEl.label,
|
|
391
429
|
dataIndex: eachHeadEl.name,
|
|
@@ -414,28 +452,13 @@ var AddMoreTable = (props) => {
|
|
|
414
452
|
}
|
|
415
453
|
});
|
|
416
454
|
});
|
|
417
|
-
if (eachRow.variable_data.length > 0) {
|
|
418
|
-
const addIconObject = {
|
|
419
|
-
id: { id: eachRow.variable_data.length + 1 },
|
|
420
|
-
Route: { label: "Route", element: "single-select", type: "text" },
|
|
421
|
-
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
422
|
-
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
423
|
-
When: { label: "When", element: "textarea", type: "text" },
|
|
424
|
-
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
425
|
-
Instructions: { label: "Instructions", element: "textarea", type: "text" },
|
|
426
|
-
addIcon: /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => console.log("Add more clicked") }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null))
|
|
427
|
-
};
|
|
428
|
-
console.log("eachrow----------", eachRow);
|
|
429
|
-
rowElements["AddMoreIcon"] = addIconObject.addIcon;
|
|
430
|
-
}
|
|
431
|
-
console.log("RowElement", rowElements);
|
|
432
455
|
}
|
|
433
456
|
return {
|
|
434
457
|
key: index.toString(),
|
|
435
458
|
"#": index + 1,
|
|
436
459
|
...eachRow,
|
|
437
460
|
...rowElements,
|
|
438
|
-
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)))
|
|
461
|
+
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)), /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onAddVariableData(index) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ import_react13.default.createElement("button", { onClick: onHandleRows }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)))
|
|
439
462
|
};
|
|
440
463
|
});
|
|
441
464
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|
package/dist/index.mjs
CHANGED
|
@@ -328,17 +328,55 @@ var AddMoreTable = (props) => {
|
|
|
328
328
|
};
|
|
329
329
|
const onHandleRows = () => {
|
|
330
330
|
const lastRow = rows[rows.length - 1];
|
|
331
|
-
const newId = lastRow ? lastRow.id + 1 :
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
331
|
+
const newId = lastRow ? lastRow.id + 1 : 1;
|
|
332
|
+
let newRow;
|
|
333
|
+
if (lastRow && lastRow.variable_data && lastRow.variable_data.length > 0) {
|
|
334
|
+
const lastVariable = lastRow.variable_data[lastRow.variable_data.length - 1];
|
|
335
|
+
const newVariableId = lastVariable.id + 1;
|
|
336
|
+
newRow = {
|
|
337
|
+
...lastRow,
|
|
338
|
+
id: newId,
|
|
339
|
+
variable_data: [
|
|
340
|
+
...lastRow.variable_data,
|
|
341
|
+
{
|
|
342
|
+
id: newVariableId,
|
|
343
|
+
icon: {}
|
|
344
|
+
}
|
|
345
|
+
]
|
|
346
|
+
};
|
|
347
|
+
} else {
|
|
348
|
+
newRow = {
|
|
349
|
+
...lastRow,
|
|
350
|
+
id: newId
|
|
351
|
+
};
|
|
352
|
+
}
|
|
336
353
|
setRows((prevData) => [...prevData, newRow]);
|
|
337
354
|
};
|
|
338
355
|
const onHandleDelete = (index) => {
|
|
339
356
|
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
340
357
|
setRows(remainingRows);
|
|
341
358
|
};
|
|
359
|
+
const onAddVariableData = (rowIndex) => {
|
|
360
|
+
setRows((prevRows) => {
|
|
361
|
+
return prevRows.map((row, index) => {
|
|
362
|
+
if (index === rowIndex && row.variable_data && row.variable_data.length > 0) {
|
|
363
|
+
const lastVariable = row.variable_data[row.variable_data.length - 1];
|
|
364
|
+
const newVariableId = lastVariable.id + 1;
|
|
365
|
+
return {
|
|
366
|
+
...row,
|
|
367
|
+
variable_data: [
|
|
368
|
+
...row.variable_data,
|
|
369
|
+
{
|
|
370
|
+
id: newVariableId,
|
|
371
|
+
icon: {}
|
|
372
|
+
}
|
|
373
|
+
]
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
return row;
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
};
|
|
342
380
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
343
381
|
title: eachHeadEl.label,
|
|
344
382
|
dataIndex: eachHeadEl.name,
|
|
@@ -367,28 +405,13 @@ var AddMoreTable = (props) => {
|
|
|
367
405
|
}
|
|
368
406
|
});
|
|
369
407
|
});
|
|
370
|
-
if (eachRow.variable_data.length > 0) {
|
|
371
|
-
const addIconObject = {
|
|
372
|
-
id: { id: eachRow.variable_data.length + 1 },
|
|
373
|
-
Route: { label: "Route", element: "single-select", type: "text" },
|
|
374
|
-
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
375
|
-
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
376
|
-
When: { label: "When", element: "textarea", type: "text" },
|
|
377
|
-
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
378
|
-
Instructions: { label: "Instructions", element: "textarea", type: "text" },
|
|
379
|
-
addIcon: /* @__PURE__ */ React12.createElement("button", { onClick: () => console.log("Add more clicked") }, /* @__PURE__ */ React12.createElement(PlusOutlined, null))
|
|
380
|
-
};
|
|
381
|
-
console.log("eachrow----------", eachRow);
|
|
382
|
-
rowElements["AddMoreIcon"] = addIconObject.addIcon;
|
|
383
|
-
}
|
|
384
|
-
console.log("RowElement", rowElements);
|
|
385
408
|
}
|
|
386
409
|
return {
|
|
387
410
|
key: index.toString(),
|
|
388
411
|
"#": index + 1,
|
|
389
412
|
...eachRow,
|
|
390
413
|
...rowElements,
|
|
391
|
-
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)))
|
|
414
|
+
actions: /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), /* @__PURE__ */ React12.createElement("button", { onClick: () => onAddVariableData(index) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ React12.createElement("button", { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)))
|
|
392
415
|
};
|
|
393
416
|
});
|
|
394
417
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|