@apexcura/ui-components 0.0.11-Beta24 → 0.0.11-Beta25
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 +71 -54
- package/dist/index.mjs +71 -54
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -376,63 +376,77 @@ var AddMoreTable = (props) => {
|
|
|
376
376
|
const onHandleRows = () => {
|
|
377
377
|
const lastRow = rows[rows.length - 1];
|
|
378
378
|
const newId = lastRow ? lastRow.id + 1 : 1;
|
|
379
|
-
let newRow
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
...
|
|
388
|
-
{
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
393
|
-
When: { label: "When", element: "textarea", type: "text" },
|
|
394
|
-
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
395
|
-
Instructions: { label: "Instructions", element: "textarea", type: "text" }
|
|
396
|
-
}
|
|
397
|
-
]
|
|
398
|
-
};
|
|
399
|
-
} else {
|
|
400
|
-
newRow = {
|
|
401
|
-
...lastRow,
|
|
402
|
-
id: newId
|
|
403
|
-
};
|
|
379
|
+
let newRow = {
|
|
380
|
+
...lastRow,
|
|
381
|
+
id: newId
|
|
382
|
+
};
|
|
383
|
+
if (newRow.variable_data && newRow.variable_data.length > 0) {
|
|
384
|
+
const updatedVariableData = newRow.variable_data.map((item, index) => {
|
|
385
|
+
const { icons, ...rest } = item;
|
|
386
|
+
return {
|
|
387
|
+
...rest,
|
|
388
|
+
icons: { delete: "", plus: index === newRow.variable_data.length - 1 ? "" : void 0 }
|
|
389
|
+
};
|
|
390
|
+
});
|
|
391
|
+
newRow.variable_data = updatedVariableData;
|
|
404
392
|
}
|
|
405
393
|
setRows((prevData) => [...prevData, newRow]);
|
|
406
394
|
};
|
|
407
395
|
const onHandleDelete = (index) => {
|
|
408
|
-
|
|
409
|
-
|
|
396
|
+
if (rows.length > 1) {
|
|
397
|
+
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
398
|
+
setRows(remainingRows);
|
|
399
|
+
}
|
|
410
400
|
};
|
|
411
|
-
const
|
|
412
|
-
setRows((prevRows) => {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
401
|
+
const onHandleVariableData = (rowId) => {
|
|
402
|
+
setRows((prevRows) => prevRows.map((row) => {
|
|
403
|
+
if (row.id === rowId) {
|
|
404
|
+
const newVariableDataId = row.variable_data.length > 0 ? row.variable_data[row.variable_data.length - 1].id + 1 : 1;
|
|
405
|
+
const newVariableData = {
|
|
406
|
+
id: newVariableDataId,
|
|
407
|
+
Route: {
|
|
408
|
+
label: "Route",
|
|
409
|
+
element: "single-select",
|
|
410
|
+
type: "text"
|
|
411
|
+
},
|
|
412
|
+
Dose: {
|
|
413
|
+
label: "Dose",
|
|
414
|
+
element: "single-select",
|
|
415
|
+
type: "text"
|
|
416
|
+
},
|
|
417
|
+
Frequency: {
|
|
418
|
+
label: "Frequency",
|
|
419
|
+
element: "single-select",
|
|
420
|
+
type: "text"
|
|
421
|
+
},
|
|
422
|
+
When: {
|
|
423
|
+
label: "When",
|
|
424
|
+
element: "textarea",
|
|
425
|
+
type: "text"
|
|
426
|
+
},
|
|
427
|
+
Duration: {
|
|
428
|
+
label: "Duration",
|
|
429
|
+
element: "textarea",
|
|
430
|
+
type: "text"
|
|
431
|
+
},
|
|
432
|
+
Instructions: {
|
|
433
|
+
label: "Instructions",
|
|
434
|
+
element: "textarea",
|
|
435
|
+
type: "text"
|
|
436
|
+
},
|
|
437
|
+
icons: { delete: "delete", plus: "plus" }
|
|
438
|
+
};
|
|
439
|
+
const updatedVariableData = [...row.variable_data, newVariableData].map((item, index, array) => ({
|
|
440
|
+
...item,
|
|
441
|
+
icons: { delete: "delete", plus: index === array.length - 1 ? "plus" : void 0 }
|
|
442
|
+
}));
|
|
443
|
+
return {
|
|
444
|
+
...row,
|
|
445
|
+
variable_data: updatedVariableData
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
return row;
|
|
449
|
+
}));
|
|
436
450
|
};
|
|
437
451
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
438
452
|
title: eachHeadEl.label,
|
|
@@ -455,11 +469,14 @@ var AddMoreTable = (props) => {
|
|
|
455
469
|
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
456
470
|
}
|
|
457
471
|
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
458
|
-
eachRow.variable_data.forEach((variable) => {
|
|
472
|
+
eachRow.variable_data.forEach((variable, varIndex) => {
|
|
459
473
|
Object.entries(variable).forEach(([key, value]) => {
|
|
460
474
|
if (value && value.element && value.label) {
|
|
461
475
|
rowElements[value.label] = renderInputElement(value);
|
|
462
476
|
}
|
|
477
|
+
if (key === "icons") {
|
|
478
|
+
rowElements[`icons_${varIndex}`] = /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, "delete"), varIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () => onHandleVariableData(eachRow.id) }, "plus"));
|
|
479
|
+
}
|
|
463
480
|
});
|
|
464
481
|
});
|
|
465
482
|
}
|
|
@@ -468,7 +485,7 @@ var AddMoreTable = (props) => {
|
|
|
468
485
|
"#": index + 1,
|
|
469
486
|
...eachRow,
|
|
470
487
|
...rowElements,
|
|
471
|
-
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)),
|
|
488
|
+
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)))
|
|
472
489
|
};
|
|
473
490
|
});
|
|
474
491
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|
package/dist/index.mjs
CHANGED
|
@@ -329,63 +329,77 @@ var AddMoreTable = (props) => {
|
|
|
329
329
|
const onHandleRows = () => {
|
|
330
330
|
const lastRow = rows[rows.length - 1];
|
|
331
331
|
const newId = lastRow ? lastRow.id + 1 : 1;
|
|
332
|
-
let newRow
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
...
|
|
341
|
-
{
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
346
|
-
When: { label: "When", element: "textarea", type: "text" },
|
|
347
|
-
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
348
|
-
Instructions: { label: "Instructions", element: "textarea", type: "text" }
|
|
349
|
-
}
|
|
350
|
-
]
|
|
351
|
-
};
|
|
352
|
-
} else {
|
|
353
|
-
newRow = {
|
|
354
|
-
...lastRow,
|
|
355
|
-
id: newId
|
|
356
|
-
};
|
|
332
|
+
let newRow = {
|
|
333
|
+
...lastRow,
|
|
334
|
+
id: newId
|
|
335
|
+
};
|
|
336
|
+
if (newRow.variable_data && newRow.variable_data.length > 0) {
|
|
337
|
+
const updatedVariableData = newRow.variable_data.map((item, index) => {
|
|
338
|
+
const { icons, ...rest } = item;
|
|
339
|
+
return {
|
|
340
|
+
...rest,
|
|
341
|
+
icons: { delete: "", plus: index === newRow.variable_data.length - 1 ? "" : void 0 }
|
|
342
|
+
};
|
|
343
|
+
});
|
|
344
|
+
newRow.variable_data = updatedVariableData;
|
|
357
345
|
}
|
|
358
346
|
setRows((prevData) => [...prevData, newRow]);
|
|
359
347
|
};
|
|
360
348
|
const onHandleDelete = (index) => {
|
|
361
|
-
|
|
362
|
-
|
|
349
|
+
if (rows.length > 1) {
|
|
350
|
+
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
351
|
+
setRows(remainingRows);
|
|
352
|
+
}
|
|
363
353
|
};
|
|
364
|
-
const
|
|
365
|
-
setRows((prevRows) => {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
354
|
+
const onHandleVariableData = (rowId) => {
|
|
355
|
+
setRows((prevRows) => prevRows.map((row) => {
|
|
356
|
+
if (row.id === rowId) {
|
|
357
|
+
const newVariableDataId = row.variable_data.length > 0 ? row.variable_data[row.variable_data.length - 1].id + 1 : 1;
|
|
358
|
+
const newVariableData = {
|
|
359
|
+
id: newVariableDataId,
|
|
360
|
+
Route: {
|
|
361
|
+
label: "Route",
|
|
362
|
+
element: "single-select",
|
|
363
|
+
type: "text"
|
|
364
|
+
},
|
|
365
|
+
Dose: {
|
|
366
|
+
label: "Dose",
|
|
367
|
+
element: "single-select",
|
|
368
|
+
type: "text"
|
|
369
|
+
},
|
|
370
|
+
Frequency: {
|
|
371
|
+
label: "Frequency",
|
|
372
|
+
element: "single-select",
|
|
373
|
+
type: "text"
|
|
374
|
+
},
|
|
375
|
+
When: {
|
|
376
|
+
label: "When",
|
|
377
|
+
element: "textarea",
|
|
378
|
+
type: "text"
|
|
379
|
+
},
|
|
380
|
+
Duration: {
|
|
381
|
+
label: "Duration",
|
|
382
|
+
element: "textarea",
|
|
383
|
+
type: "text"
|
|
384
|
+
},
|
|
385
|
+
Instructions: {
|
|
386
|
+
label: "Instructions",
|
|
387
|
+
element: "textarea",
|
|
388
|
+
type: "text"
|
|
389
|
+
},
|
|
390
|
+
icons: { delete: "delete", plus: "plus" }
|
|
391
|
+
};
|
|
392
|
+
const updatedVariableData = [...row.variable_data, newVariableData].map((item, index, array) => ({
|
|
393
|
+
...item,
|
|
394
|
+
icons: { delete: "delete", plus: index === array.length - 1 ? "plus" : void 0 }
|
|
395
|
+
}));
|
|
396
|
+
return {
|
|
397
|
+
...row,
|
|
398
|
+
variable_data: updatedVariableData
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
return row;
|
|
402
|
+
}));
|
|
389
403
|
};
|
|
390
404
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
391
405
|
title: eachHeadEl.label,
|
|
@@ -408,11 +422,14 @@ var AddMoreTable = (props) => {
|
|
|
408
422
|
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
409
423
|
}
|
|
410
424
|
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
411
|
-
eachRow.variable_data.forEach((variable) => {
|
|
425
|
+
eachRow.variable_data.forEach((variable, varIndex) => {
|
|
412
426
|
Object.entries(variable).forEach(([key, value]) => {
|
|
413
427
|
if (value && value.element && value.label) {
|
|
414
428
|
rowElements[value.label] = renderInputElement(value);
|
|
415
429
|
}
|
|
430
|
+
if (key === "icons") {
|
|
431
|
+
rowElements[`icons_${varIndex}`] = /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, "delete"), varIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleVariableData(eachRow.id) }, "plus"));
|
|
432
|
+
}
|
|
416
433
|
});
|
|
417
434
|
});
|
|
418
435
|
}
|
|
@@ -421,7 +438,7 @@ var AddMoreTable = (props) => {
|
|
|
421
438
|
"#": index + 1,
|
|
422
439
|
...eachRow,
|
|
423
440
|
...rowElements,
|
|
424
|
-
actions: /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)),
|
|
441
|
+
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)))
|
|
425
442
|
};
|
|
426
443
|
});
|
|
427
444
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|