@apexcura/ui-components 0.0.12-Beta12 → 0.0.12-Beta13
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 +62 -17
- package/dist/index.mjs +62 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -375,17 +375,65 @@ 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.id + 1;
|
|
383
|
+
newRow = {
|
|
384
|
+
...lastRow,
|
|
385
|
+
id: newId,
|
|
386
|
+
variable_data: [
|
|
387
|
+
...lastRow.variable_data,
|
|
388
|
+
{
|
|
389
|
+
id: { id: newVariableId },
|
|
390
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
391
|
+
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
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
|
+
};
|
|
404
|
+
}
|
|
383
405
|
setRows((prevData) => [...prevData, newRow]);
|
|
384
406
|
};
|
|
385
407
|
const onHandleDelete = (index) => {
|
|
386
408
|
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
387
409
|
setRows(remainingRows);
|
|
388
410
|
};
|
|
411
|
+
const onAddVariableData = (rowIndex) => {
|
|
412
|
+
setRows((prevRows) => {
|
|
413
|
+
return prevRows.map((row, index) => {
|
|
414
|
+
if (index === rowIndex && row.variable_data && row.variable_data.length > 0) {
|
|
415
|
+
const lastVariable = row.variable_data[row.variable_data.length - 1];
|
|
416
|
+
const newVariableId = lastVariable.id.id + 1;
|
|
417
|
+
return {
|
|
418
|
+
...row,
|
|
419
|
+
variable_data: [
|
|
420
|
+
...row.variable_data,
|
|
421
|
+
{
|
|
422
|
+
id: { id: newVariableId },
|
|
423
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
424
|
+
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
425
|
+
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
426
|
+
When: { label: "When", element: "textarea", type: "text" },
|
|
427
|
+
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
428
|
+
Instructions: { label: "Instructions", element: "textarea", type: "text" }
|
|
429
|
+
}
|
|
430
|
+
]
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
return row;
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
};
|
|
389
437
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
390
438
|
title: eachHeadEl.label,
|
|
391
439
|
dataIndex: eachHeadEl.name,
|
|
@@ -393,7 +441,6 @@ var AddMoreTable = (props) => {
|
|
|
393
441
|
})) : [];
|
|
394
442
|
const renderInputElement = (element) => {
|
|
395
443
|
const { element: type, label } = element;
|
|
396
|
-
console.log("type....", type);
|
|
397
444
|
if (type === "single-select") {
|
|
398
445
|
return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
|
|
399
446
|
} else if (type === "textarea") {
|
|
@@ -407,23 +454,21 @@ var AddMoreTable = (props) => {
|
|
|
407
454
|
if (eachRow.element && eachRow.label) {
|
|
408
455
|
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
409
456
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
Object.
|
|
413
|
-
if (
|
|
414
|
-
rowElements[
|
|
457
|
+
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
458
|
+
eachRow.variable_data.forEach((variable) => {
|
|
459
|
+
Object.entries(variable).forEach(([key, value]) => {
|
|
460
|
+
if (value && value.element && value.label) {
|
|
461
|
+
rowElements[value.label] = renderInputElement(value);
|
|
415
462
|
}
|
|
416
|
-
})
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
}, {}) : {};
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
}
|
|
420
466
|
return {
|
|
421
467
|
key: index.toString(),
|
|
422
468
|
"#": index + 1,
|
|
423
469
|
...eachRow,
|
|
424
470
|
...rowElements,
|
|
425
|
-
|
|
426
|
-
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)))
|
|
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)), /* @__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)))
|
|
427
472
|
};
|
|
428
473
|
});
|
|
429
474
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|
package/dist/index.mjs
CHANGED
|
@@ -328,17 +328,65 @@ 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.id + 1;
|
|
336
|
+
newRow = {
|
|
337
|
+
...lastRow,
|
|
338
|
+
id: newId,
|
|
339
|
+
variable_data: [
|
|
340
|
+
...lastRow.variable_data,
|
|
341
|
+
{
|
|
342
|
+
id: { id: newVariableId },
|
|
343
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
344
|
+
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
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
|
+
};
|
|
357
|
+
}
|
|
336
358
|
setRows((prevData) => [...prevData, newRow]);
|
|
337
359
|
};
|
|
338
360
|
const onHandleDelete = (index) => {
|
|
339
361
|
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
340
362
|
setRows(remainingRows);
|
|
341
363
|
};
|
|
364
|
+
const onAddVariableData = (rowIndex) => {
|
|
365
|
+
setRows((prevRows) => {
|
|
366
|
+
return prevRows.map((row, index) => {
|
|
367
|
+
if (index === rowIndex && row.variable_data && row.variable_data.length > 0) {
|
|
368
|
+
const lastVariable = row.variable_data[row.variable_data.length - 1];
|
|
369
|
+
const newVariableId = lastVariable.id.id + 1;
|
|
370
|
+
return {
|
|
371
|
+
...row,
|
|
372
|
+
variable_data: [
|
|
373
|
+
...row.variable_data,
|
|
374
|
+
{
|
|
375
|
+
id: { id: newVariableId },
|
|
376
|
+
Route: { label: "Route", element: "single-select", type: "text" },
|
|
377
|
+
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
378
|
+
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
379
|
+
When: { label: "When", element: "textarea", type: "text" },
|
|
380
|
+
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
381
|
+
Instructions: { label: "Instructions", element: "textarea", type: "text" }
|
|
382
|
+
}
|
|
383
|
+
]
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
return row;
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
};
|
|
342
390
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
343
391
|
title: eachHeadEl.label,
|
|
344
392
|
dataIndex: eachHeadEl.name,
|
|
@@ -346,7 +394,6 @@ var AddMoreTable = (props) => {
|
|
|
346
394
|
})) : [];
|
|
347
395
|
const renderInputElement = (element) => {
|
|
348
396
|
const { element: type, label } = element;
|
|
349
|
-
console.log("type....", type);
|
|
350
397
|
if (type === "single-select") {
|
|
351
398
|
return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
|
|
352
399
|
} else if (type === "textarea") {
|
|
@@ -360,23 +407,21 @@ var AddMoreTable = (props) => {
|
|
|
360
407
|
if (eachRow.element && eachRow.label) {
|
|
361
408
|
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
362
409
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
Object.
|
|
366
|
-
if (
|
|
367
|
-
rowElements[
|
|
410
|
+
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
411
|
+
eachRow.variable_data.forEach((variable) => {
|
|
412
|
+
Object.entries(variable).forEach(([key, value]) => {
|
|
413
|
+
if (value && value.element && value.label) {
|
|
414
|
+
rowElements[value.label] = renderInputElement(value);
|
|
368
415
|
}
|
|
369
|
-
})
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
}, {}) : {};
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
}
|
|
373
419
|
return {
|
|
374
420
|
key: index.toString(),
|
|
375
421
|
"#": index + 1,
|
|
376
422
|
...eachRow,
|
|
377
423
|
...rowElements,
|
|
378
|
-
|
|
379
|
-
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)))
|
|
424
|
+
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)))
|
|
380
425
|
};
|
|
381
426
|
});
|
|
382
427
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|