@apexcura/ui-components 0.0.12-Beta18 → 0.0.12-Beta19

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 CHANGED
@@ -402,6 +402,58 @@ var AddMoreTable = (props) => {
402
402
  setRows(remainingRows);
403
403
  }
404
404
  };
405
+ const onHandleVariableData = (rowId) => {
406
+ setRows((prevRows) => prevRows.map((row) => {
407
+ if (row.id === rowId) {
408
+ const newVariableDataId = row.variable_data.length > 0 ? row.variable_data[row.variable_data.length - 1].id + 1 : 1;
409
+ const newVariableData = {
410
+ id: newVariableDataId,
411
+ Route: {
412
+ label: "Route",
413
+ element: "single-select",
414
+ type: "text"
415
+ },
416
+ Dose: {
417
+ label: "Dose",
418
+ element: "single-select",
419
+ type: "text"
420
+ },
421
+ Frequency: {
422
+ label: "Frequency",
423
+ element: "single-select",
424
+ type: "text"
425
+ },
426
+ When: {
427
+ label: "When",
428
+ element: "textarea",
429
+ type: "text"
430
+ },
431
+ Duration: {
432
+ label: "Duration",
433
+ element: "textarea",
434
+ type: "text"
435
+ },
436
+ Instructions: {
437
+ label: "Instructions",
438
+ element: "textarea",
439
+ type: "text"
440
+ },
441
+ icons: { delete: "", plus: "" }
442
+ };
443
+ const updatedVariableData = [...row.variable_data, newVariableData];
444
+ updatedVariableData.forEach((data, index) => {
445
+ if (index === updatedVariableData.length - 1) {
446
+ data.icons.plus = "";
447
+ }
448
+ });
449
+ return {
450
+ ...row,
451
+ variable_data: updatedVariableData
452
+ };
453
+ }
454
+ return row;
455
+ }));
456
+ };
405
457
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
406
458
  title: eachHeadEl.label,
407
459
  dataIndex: eachHeadEl.name,
@@ -429,7 +481,7 @@ var AddMoreTable = (props) => {
429
481
  rowElements[value.label] = renderInputElement(value);
430
482
  }
431
483
  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));
484
+ 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("button", { onClick: () => onHandleVariableData(eachRow.id) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
433
485
  }
434
486
  });
435
487
  });
package/dist/index.mjs CHANGED
@@ -355,6 +355,58 @@ var AddMoreTable = (props) => {
355
355
  setRows(remainingRows);
356
356
  }
357
357
  };
358
+ const onHandleVariableData = (rowId) => {
359
+ setRows((prevRows) => prevRows.map((row) => {
360
+ if (row.id === rowId) {
361
+ const newVariableDataId = row.variable_data.length > 0 ? row.variable_data[row.variable_data.length - 1].id + 1 : 1;
362
+ const newVariableData = {
363
+ id: newVariableDataId,
364
+ Route: {
365
+ label: "Route",
366
+ element: "single-select",
367
+ type: "text"
368
+ },
369
+ Dose: {
370
+ label: "Dose",
371
+ element: "single-select",
372
+ type: "text"
373
+ },
374
+ Frequency: {
375
+ label: "Frequency",
376
+ element: "single-select",
377
+ type: "text"
378
+ },
379
+ When: {
380
+ label: "When",
381
+ element: "textarea",
382
+ type: "text"
383
+ },
384
+ Duration: {
385
+ label: "Duration",
386
+ element: "textarea",
387
+ type: "text"
388
+ },
389
+ Instructions: {
390
+ label: "Instructions",
391
+ element: "textarea",
392
+ type: "text"
393
+ },
394
+ icons: { delete: "", plus: "" }
395
+ };
396
+ const updatedVariableData = [...row.variable_data, newVariableData];
397
+ updatedVariableData.forEach((data, index) => {
398
+ if (index === updatedVariableData.length - 1) {
399
+ data.icons.plus = "";
400
+ }
401
+ });
402
+ return {
403
+ ...row,
404
+ variable_data: updatedVariableData
405
+ };
406
+ }
407
+ return row;
408
+ }));
409
+ };
358
410
  const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
359
411
  title: eachHeadEl.label,
360
412
  dataIndex: eachHeadEl.name,
@@ -382,7 +434,7 @@ var AddMoreTable = (props) => {
382
434
  rowElements[value.label] = renderInputElement(value);
383
435
  }
384
436
  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));
437
+ 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("button", { onClick: () => onHandleVariableData(eachRow.id) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
386
438
  }
387
439
  });
388
440
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.12-Beta18",
3
+ "version": "0.0.12-Beta19",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",