@apexcura/ui-components 0.0.12-Beta17 → 0.0.12-Beta18
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 +23 -23
- package/dist/index.mjs +23 -23
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -376,34 +376,31 @@ 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
|
-
newRow = {
|
|
379
|
+
let newRow = {
|
|
381
380
|
...lastRow,
|
|
382
381
|
id: newId
|
|
383
|
-
// variable_data: [
|
|
384
|
-
// ...lastRow.variable_data,
|
|
385
|
-
// {
|
|
386
|
-
// id: { id: newVariableId },
|
|
387
|
-
// Route: { label: "Route", element: "single-select", type: "text" },
|
|
388
|
-
// Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
389
|
-
// Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
390
|
-
// When: { label: "When", element: "textarea", type: "text" },
|
|
391
|
-
// Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
392
|
-
// Instructions: { label: "Instructions", element: "textarea", type: "text" }
|
|
393
|
-
// }
|
|
394
|
-
// // ],
|
|
395
|
-
// };
|
|
396
|
-
// } else {
|
|
397
|
-
// newRow = {
|
|
398
|
-
// ...lastRow,
|
|
399
|
-
// id: newId,
|
|
400
|
-
// };
|
|
401
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: { ...icons, delete: "" }
|
|
389
|
+
};
|
|
390
|
+
});
|
|
391
|
+
updatedVariableData[updatedVariableData.length - 1] = {
|
|
392
|
+
...updatedVariableData[updatedVariableData.length - 1],
|
|
393
|
+
icons: { ...updatedVariableData[updatedVariableData.length - 1].icons, plus: "" }
|
|
394
|
+
};
|
|
395
|
+
newRow.variable_data = updatedVariableData;
|
|
396
|
+
}
|
|
402
397
|
setRows((prevData) => [...prevData, newRow]);
|
|
403
398
|
};
|
|
404
399
|
const onHandleDelete = (index) => {
|
|
405
|
-
|
|
406
|
-
|
|
400
|
+
if (rows.length > 1) {
|
|
401
|
+
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
402
|
+
setRows(remainingRows);
|
|
403
|
+
}
|
|
407
404
|
};
|
|
408
405
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
409
406
|
title: eachHeadEl.label,
|
|
@@ -426,11 +423,14 @@ var AddMoreTable = (props) => {
|
|
|
426
423
|
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
427
424
|
}
|
|
428
425
|
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
429
|
-
eachRow.variable_data.forEach((variable) => {
|
|
426
|
+
eachRow.variable_data.forEach((variable, varIndex) => {
|
|
430
427
|
Object.entries(variable).forEach(([key, value]) => {
|
|
431
428
|
if (value && value.element && value.label) {
|
|
432
429
|
rowElements[value.label] = renderInputElement(value);
|
|
433
430
|
}
|
|
431
|
+
if (key === "icons") {
|
|
432
|
+
rowElements[`icons_${varIndex}`] = /* @__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)), varIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null));
|
|
433
|
+
}
|
|
434
434
|
});
|
|
435
435
|
});
|
|
436
436
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -329,34 +329,31 @@ 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
|
-
newRow = {
|
|
332
|
+
let newRow = {
|
|
334
333
|
...lastRow,
|
|
335
334
|
id: newId
|
|
336
|
-
// variable_data: [
|
|
337
|
-
// ...lastRow.variable_data,
|
|
338
|
-
// {
|
|
339
|
-
// id: { id: newVariableId },
|
|
340
|
-
// Route: { label: "Route", element: "single-select", type: "text" },
|
|
341
|
-
// Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
342
|
-
// Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
343
|
-
// When: { label: "When", element: "textarea", type: "text" },
|
|
344
|
-
// Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
345
|
-
// Instructions: { label: "Instructions", element: "textarea", type: "text" }
|
|
346
|
-
// }
|
|
347
|
-
// // ],
|
|
348
|
-
// };
|
|
349
|
-
// } else {
|
|
350
|
-
// newRow = {
|
|
351
|
-
// ...lastRow,
|
|
352
|
-
// id: newId,
|
|
353
|
-
// };
|
|
354
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: { ...icons, delete: "" }
|
|
342
|
+
};
|
|
343
|
+
});
|
|
344
|
+
updatedVariableData[updatedVariableData.length - 1] = {
|
|
345
|
+
...updatedVariableData[updatedVariableData.length - 1],
|
|
346
|
+
icons: { ...updatedVariableData[updatedVariableData.length - 1].icons, plus: "" }
|
|
347
|
+
};
|
|
348
|
+
newRow.variable_data = updatedVariableData;
|
|
349
|
+
}
|
|
355
350
|
setRows((prevData) => [...prevData, newRow]);
|
|
356
351
|
};
|
|
357
352
|
const onHandleDelete = (index) => {
|
|
358
|
-
|
|
359
|
-
|
|
353
|
+
if (rows.length > 1) {
|
|
354
|
+
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
355
|
+
setRows(remainingRows);
|
|
356
|
+
}
|
|
360
357
|
};
|
|
361
358
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
362
359
|
title: eachHeadEl.label,
|
|
@@ -379,11 +376,14 @@ var AddMoreTable = (props) => {
|
|
|
379
376
|
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
380
377
|
}
|
|
381
378
|
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
382
|
-
eachRow.variable_data.forEach((variable) => {
|
|
379
|
+
eachRow.variable_data.forEach((variable, varIndex) => {
|
|
383
380
|
Object.entries(variable).forEach(([key, value]) => {
|
|
384
381
|
if (value && value.element && value.label) {
|
|
385
382
|
rowElements[value.label] = renderInputElement(value);
|
|
386
383
|
}
|
|
384
|
+
if (key === "icons") {
|
|
385
|
+
rowElements[`icons_${varIndex}`] = /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), varIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement(PlusOutlined, null));
|
|
386
|
+
}
|
|
387
387
|
});
|
|
388
388
|
});
|
|
389
389
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apexcura/ui-components",
|
|
3
|
-
"version": "0.0.12-
|
|
3
|
+
"version": "0.0.12-Beta18",
|
|
4
4
|
"description": "Apex cura React components library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex cura",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"node": ">=18.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
+
"@apexcura/ui-components": "^0.0.12-Beta17",
|
|
51
52
|
"@tinymce/tinymce-react": "^5.0.1"
|
|
52
53
|
}
|
|
53
54
|
}
|