@apexcura/ui-components 0.0.12-Beta16 → 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 +25 -56
- package/dist/index.mjs +25 -56
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -376,65 +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
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
...
|
|
388
|
-
{
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
|
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: { ...icons, delete: "" }
|
|
389
|
+
};
|
|
390
|
+
});
|
|
391
|
+
updatedVariableData[updatedVariableData.length - 1] = {
|
|
392
|
+
...updatedVariableData[updatedVariableData.length - 1],
|
|
393
|
+
icons: { ...updatedVariableData[updatedVariableData.length - 1].icons, plus: "" }
|
|
403
394
|
};
|
|
395
|
+
newRow.variable_data = updatedVariableData;
|
|
404
396
|
}
|
|
405
397
|
setRows((prevData) => [...prevData, newRow]);
|
|
406
398
|
};
|
|
407
399
|
const onHandleDelete = (index) => {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
setRows((prevRows) => {
|
|
413
|
-
return prevRows.map((row, index) => {
|
|
414
|
-
console.log("row", row);
|
|
415
|
-
if (index === rowIndex && row.variable_data && row.variable_data.length > 0) {
|
|
416
|
-
const lastVariable = row.variable_data[row.variable_data.length - 1];
|
|
417
|
-
const newVariableId = lastVariable.id.id + 1;
|
|
418
|
-
return {
|
|
419
|
-
...row,
|
|
420
|
-
variable_data: [
|
|
421
|
-
...row.variable_data,
|
|
422
|
-
{
|
|
423
|
-
id: { id: newVariableId },
|
|
424
|
-
Route: { label: "Route", element: "single-select", type: "text" },
|
|
425
|
-
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
426
|
-
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
427
|
-
When: { label: "When", element: "textarea", type: "text" },
|
|
428
|
-
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
429
|
-
Instructions: { label: "Instructions", element: "textarea", type: "text" }
|
|
430
|
-
}
|
|
431
|
-
]
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
return row;
|
|
435
|
-
console.log("---------------row", row);
|
|
436
|
-
});
|
|
437
|
-
});
|
|
400
|
+
if (rows.length > 1) {
|
|
401
|
+
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
402
|
+
setRows(remainingRows);
|
|
403
|
+
}
|
|
438
404
|
};
|
|
439
405
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
440
406
|
title: eachHeadEl.label,
|
|
@@ -457,11 +423,14 @@ var AddMoreTable = (props) => {
|
|
|
457
423
|
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
458
424
|
}
|
|
459
425
|
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
460
|
-
eachRow.variable_data.forEach((variable) => {
|
|
426
|
+
eachRow.variable_data.forEach((variable, varIndex) => {
|
|
461
427
|
Object.entries(variable).forEach(([key, value]) => {
|
|
462
428
|
if (value && value.element && value.label) {
|
|
463
429
|
rowElements[value.label] = renderInputElement(value);
|
|
464
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
|
+
}
|
|
465
434
|
});
|
|
466
435
|
});
|
|
467
436
|
}
|
|
@@ -470,7 +439,7 @@ var AddMoreTable = (props) => {
|
|
|
470
439
|
"#": index + 1,
|
|
471
440
|
...eachRow,
|
|
472
441
|
...rowElements,
|
|
473
|
-
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)),
|
|
442
|
+
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)))
|
|
474
443
|
};
|
|
475
444
|
});
|
|
476
445
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|
package/dist/index.mjs
CHANGED
|
@@ -329,65 +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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
...
|
|
341
|
-
{
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
|
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: { ...icons, delete: "" }
|
|
342
|
+
};
|
|
343
|
+
});
|
|
344
|
+
updatedVariableData[updatedVariableData.length - 1] = {
|
|
345
|
+
...updatedVariableData[updatedVariableData.length - 1],
|
|
346
|
+
icons: { ...updatedVariableData[updatedVariableData.length - 1].icons, plus: "" }
|
|
356
347
|
};
|
|
348
|
+
newRow.variable_data = updatedVariableData;
|
|
357
349
|
}
|
|
358
350
|
setRows((prevData) => [...prevData, newRow]);
|
|
359
351
|
};
|
|
360
352
|
const onHandleDelete = (index) => {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
setRows((prevRows) => {
|
|
366
|
-
return prevRows.map((row, index) => {
|
|
367
|
-
console.log("row", row);
|
|
368
|
-
if (index === rowIndex && row.variable_data && row.variable_data.length > 0) {
|
|
369
|
-
const lastVariable = row.variable_data[row.variable_data.length - 1];
|
|
370
|
-
const newVariableId = lastVariable.id.id + 1;
|
|
371
|
-
return {
|
|
372
|
-
...row,
|
|
373
|
-
variable_data: [
|
|
374
|
-
...row.variable_data,
|
|
375
|
-
{
|
|
376
|
-
id: { id: newVariableId },
|
|
377
|
-
Route: { label: "Route", element: "single-select", type: "text" },
|
|
378
|
-
Dose: { label: "Dose", element: "single-select", type: "text" },
|
|
379
|
-
Frequency: { label: "Frequency", element: "single-select", type: "text" },
|
|
380
|
-
When: { label: "When", element: "textarea", type: "text" },
|
|
381
|
-
Duration: { label: "Duration", element: "textarea", type: "text" },
|
|
382
|
-
Instructions: { label: "Instructions", element: "textarea", type: "text" }
|
|
383
|
-
}
|
|
384
|
-
]
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
return row;
|
|
388
|
-
console.log("---------------row", row);
|
|
389
|
-
});
|
|
390
|
-
});
|
|
353
|
+
if (rows.length > 1) {
|
|
354
|
+
const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
|
|
355
|
+
setRows(remainingRows);
|
|
356
|
+
}
|
|
391
357
|
};
|
|
392
358
|
const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
|
|
393
359
|
title: eachHeadEl.label,
|
|
@@ -410,11 +376,14 @@ var AddMoreTable = (props) => {
|
|
|
410
376
|
rowElements[eachRow.label] = renderInputElement(eachRow);
|
|
411
377
|
}
|
|
412
378
|
if (eachRow.variable_data && Array.isArray(eachRow.variable_data)) {
|
|
413
|
-
eachRow.variable_data.forEach((variable) => {
|
|
379
|
+
eachRow.variable_data.forEach((variable, varIndex) => {
|
|
414
380
|
Object.entries(variable).forEach(([key, value]) => {
|
|
415
381
|
if (value && value.element && value.label) {
|
|
416
382
|
rowElements[value.label] = renderInputElement(value);
|
|
417
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
|
+
}
|
|
418
387
|
});
|
|
419
388
|
});
|
|
420
389
|
}
|
|
@@ -423,7 +392,7 @@ var AddMoreTable = (props) => {
|
|
|
423
392
|
"#": index + 1,
|
|
424
393
|
...eachRow,
|
|
425
394
|
...rowElements,
|
|
426
|
-
actions: /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)),
|
|
395
|
+
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)))
|
|
427
396
|
};
|
|
428
397
|
});
|
|
429
398
|
if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
|
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
|
}
|