@apexcura/ui-components 0.0.11-Beta23 → 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 -48
- package/dist/index.mjs +71 -48
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -376,57 +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
|
-
]
|
|
393
|
-
};
|
|
394
|
-
} else {
|
|
395
|
-
newRow = {
|
|
396
|
-
...lastRow,
|
|
397
|
-
id: newId
|
|
398
|
-
};
|
|
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;
|
|
399
392
|
}
|
|
400
393
|
setRows((prevData) => [...prevData, newRow]);
|
|
401
394
|
};
|
|
402
395
|
const onHandleDelete = (index) => {
|
|
403
|
-
|
|
404
|
-
|
|
396
|
+
if (rows.length > 1) {
|
|
397
|
+
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
398
|
+
setRows(remainingRows);
|
|
399
|
+
}
|
|
405
400
|
};
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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
|
+
}));
|
|
430
450
|
};
|
|
431
451
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
432
452
|
title: eachHeadEl.label,
|
|
@@ -449,11 +469,14 @@ var AddMoreTable = (props) => {
|
|
|
449
469
|
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
450
470
|
}
|
|
451
471
|
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
452
|
-
eachRow.variable_data.forEach((variable) => {
|
|
472
|
+
eachRow.variable_data.forEach((variable, varIndex) => {
|
|
453
473
|
Object.entries(variable).forEach(([key, value]) => {
|
|
454
474
|
if (value && value.element && value.label) {
|
|
455
475
|
rowElements[value.label] = renderInputElement(value);
|
|
456
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
|
+
}
|
|
457
480
|
});
|
|
458
481
|
});
|
|
459
482
|
}
|
|
@@ -462,7 +485,7 @@ var AddMoreTable = (props) => {
|
|
|
462
485
|
"#": index + 1,
|
|
463
486
|
...eachRow,
|
|
464
487
|
...rowElements,
|
|
465
|
-
actions: /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("button", { onClick: () =>
|
|
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)))
|
|
466
489
|
};
|
|
467
490
|
});
|
|
468
491
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|
package/dist/index.mjs
CHANGED
|
@@ -329,57 +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
|
-
]
|
|
346
|
-
};
|
|
347
|
-
} else {
|
|
348
|
-
newRow = {
|
|
349
|
-
...lastRow,
|
|
350
|
-
id: newId
|
|
351
|
-
};
|
|
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;
|
|
352
345
|
}
|
|
353
346
|
setRows((prevData) => [...prevData, newRow]);
|
|
354
347
|
};
|
|
355
348
|
const onHandleDelete = (index) => {
|
|
356
|
-
|
|
357
|
-
|
|
349
|
+
if (rows.length > 1) {
|
|
350
|
+
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
351
|
+
setRows(remainingRows);
|
|
352
|
+
}
|
|
358
353
|
};
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
+
}));
|
|
383
403
|
};
|
|
384
404
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
385
405
|
title: eachHeadEl.label,
|
|
@@ -402,11 +422,14 @@ var AddMoreTable = (props) => {
|
|
|
402
422
|
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
403
423
|
}
|
|
404
424
|
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
405
|
-
eachRow.variable_data.forEach((variable) => {
|
|
425
|
+
eachRow.variable_data.forEach((variable, varIndex) => {
|
|
406
426
|
Object.entries(variable).forEach(([key, value]) => {
|
|
407
427
|
if (value && value.element && value.label) {
|
|
408
428
|
rowElements[value.label] = renderInputElement(value);
|
|
409
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
|
+
}
|
|
410
433
|
});
|
|
411
434
|
});
|
|
412
435
|
}
|
|
@@ -415,7 +438,7 @@ var AddMoreTable = (props) => {
|
|
|
415
438
|
"#": index + 1,
|
|
416
439
|
...eachRow,
|
|
417
440
|
...rowElements,
|
|
418
|
-
actions: /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () =>
|
|
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)))
|
|
419
442
|
};
|
|
420
443
|
});
|
|
421
444
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|