@apexcura/ui-components 0.0.11-Beta20 → 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 -19
- package/dist/index.mjs +44 -19
- 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,26 +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
|
-
rowElements["AddMoreIcon"] = addIconObject.addIcon;
|
|
429
|
-
}
|
|
430
455
|
}
|
|
431
456
|
return {
|
|
432
457
|
key: index.toString(),
|
|
433
458
|
"#": index + 1,
|
|
434
459
|
...eachRow,
|
|
435
460
|
...rowElements,
|
|
436
|
-
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)))
|
|
437
462
|
};
|
|
438
463
|
});
|
|
439
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,26 +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
|
-
rowElements["AddMoreIcon"] = addIconObject.addIcon;
|
|
382
|
-
}
|
|
383
408
|
}
|
|
384
409
|
return {
|
|
385
410
|
key: index.toString(),
|
|
386
411
|
"#": index + 1,
|
|
387
412
|
...eachRow,
|
|
388
413
|
...rowElements,
|
|
389
|
-
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)))
|
|
390
415
|
};
|
|
391
416
|
});
|
|
392
417
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|