@apexcura/ui-components 0.0.12-Beta3 → 0.0.12-Beta30

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.d.mts CHANGED
@@ -1,13 +1,14 @@
1
1
  import React$1 from 'react';
2
2
 
3
3
  type ElementType = {
4
+ className: string | undefined;
4
5
  placeholder?: string;
5
6
  addonBefore?: React.ReactNode;
6
7
  defaultValue?: string;
7
8
  disabled?: boolean;
8
9
  prefix?: React.ReactNode;
9
10
  type?: string;
10
- value?: string | number | boolean | any[];
11
+ value?: string | number | boolean | any[] | null;
11
12
  status?: "error" | "warning";
12
13
  styles?: React.CSSProperties;
13
14
  classNames?: string;
@@ -17,12 +18,16 @@ type ElementType = {
17
18
  suffix?: React.ReactNode;
18
19
  maxLength?: number;
19
20
  fieldNames?: any[];
21
+ options?: any[];
20
22
  onChange?: (value: string | number | boolean | any[]) => void;
21
23
  dropDownOptions?: any[];
22
24
  id?: number;
23
25
  thead?: any[];
24
26
  tbody?: any[];
25
27
  variable_data?: any[];
28
+ optionType?: string;
29
+ selectedClassName?: string;
30
+ action?: React.MouseEventHandler<HTMLElement> | string;
26
31
  };
27
32
 
28
33
  interface ElementExecuterProps$3 extends ElementType {
@@ -67,7 +72,7 @@ declare const SingleSelectElement: (props: ElementType) => React$1.JSX.Element;
67
72
 
68
73
  declare const MultipleSelectElement: (props: ElementType) => React$1.JSX.Element;
69
74
 
70
- declare const ButtonElement: () => React$1.JSX.Element;
75
+ declare const ButtonElement: (props: ElementType) => React$1.JSX.Element;
71
76
 
72
77
  declare const AddMoreTable: (props: ElementType) => React$1.JSX.Element;
73
78
 
package/dist/index.d.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  import React$1 from 'react';
2
2
 
3
3
  type ElementType = {
4
+ className: string | undefined;
4
5
  placeholder?: string;
5
6
  addonBefore?: React.ReactNode;
6
7
  defaultValue?: string;
7
8
  disabled?: boolean;
8
9
  prefix?: React.ReactNode;
9
10
  type?: string;
10
- value?: string | number | boolean | any[];
11
+ value?: string | number | boolean | any[] | null;
11
12
  status?: "error" | "warning";
12
13
  styles?: React.CSSProperties;
13
14
  classNames?: string;
@@ -17,12 +18,16 @@ type ElementType = {
17
18
  suffix?: React.ReactNode;
18
19
  maxLength?: number;
19
20
  fieldNames?: any[];
21
+ options?: any[];
20
22
  onChange?: (value: string | number | boolean | any[]) => void;
21
23
  dropDownOptions?: any[];
22
24
  id?: number;
23
25
  thead?: any[];
24
26
  tbody?: any[];
25
27
  variable_data?: any[];
28
+ optionType?: string;
29
+ selectedClassName?: string;
30
+ action?: React.MouseEventHandler<HTMLElement> | string;
26
31
  };
27
32
 
28
33
  interface ElementExecuterProps$3 extends ElementType {
@@ -67,7 +72,7 @@ declare const SingleSelectElement: (props: ElementType) => React$1.JSX.Element;
67
72
 
68
73
  declare const MultipleSelectElement: (props: ElementType) => React$1.JSX.Element;
69
74
 
70
- declare const ButtonElement: () => React$1.JSX.Element;
75
+ declare const ButtonElement: (props: ElementType) => React$1.JSX.Element;
71
76
 
72
77
  declare const AddMoreTable: (props: ElementType) => React$1.JSX.Element;
73
78
 
package/dist/index.js CHANGED
@@ -115,7 +115,6 @@ var NumberElement = (props) => {
115
115
  prefix: props.prefix,
116
116
  type: props.type,
117
117
  status: props.status,
118
- style: props.styles,
119
118
  className: props.classNames,
120
119
  variant: props.variant,
121
120
  name: props.name,
@@ -138,7 +137,6 @@ var TextareaElement = (props) => {
138
137
  disabled: props.disabled,
139
138
  id: props.name,
140
139
  status: props.status,
141
- style: props.styles,
142
140
  className: props.classNames,
143
141
  variant: props.variant,
144
142
  name: props.name,
@@ -188,14 +186,47 @@ var SelectElement = (props) => {
188
186
  var import_react6 = __toESM(require("react"));
189
187
  var import_antd6 = require("antd");
190
188
  var RadioElement = (props) => {
189
+ const [isDisabled, setIsDisabled] = (0, import_react6.useState)(props.disabled);
190
+ const [selectedValue, setSelectedValue] = (0, import_react6.useState)(props.value);
191
+ let optionType;
192
+ if (props.optionType === "button") {
193
+ optionType = props.optionType;
194
+ }
195
+ (0, import_react6.useEffect)(() => {
196
+ setIsDisabled(props.disabled);
197
+ }, [props.disabled]);
191
198
  const handleChange = (e) => {
199
+ const selectedVal = e.target.value;
200
+ const selectedOptions = [{ id: selectedVal, value: selectedVal }];
201
+ setSelectedValue(selectedVal);
202
+ setIsDisabled(true);
192
203
  if (props.onChange) {
193
- const selectedVal = e.target.value;
194
- const selectedOptions = [{ id: selectedVal, value: selectedVal }];
195
204
  props.onChange(selectedOptions);
196
205
  }
197
206
  };
198
- return /* @__PURE__ */ import_react6.default.createElement(import_antd6.Radio.Group, { name: "radiogroup", defaultValue: 1 }, /* @__PURE__ */ import_react6.default.createElement(import_antd6.Radio, { value: 1, onChange: handleChange }, "A"), /* @__PURE__ */ import_react6.default.createElement(import_antd6.Radio, { value: 2, onChange: handleChange }, "B"), /* @__PURE__ */ import_react6.default.createElement(import_antd6.Radio, { value: 3, onChange: handleChange }, "C"), /* @__PURE__ */ import_react6.default.createElement(import_antd6.Radio, { value: 4, onChange: handleChange }, "D"));
207
+ const getButtonStyle = (option) => {
208
+ return selectedValue === option.value ? option.selectedClassName : option.className;
209
+ };
210
+ return /* @__PURE__ */ import_react6.default.createElement(
211
+ import_antd6.Radio.Group,
212
+ {
213
+ onChange: handleChange,
214
+ optionType,
215
+ className: props.className ? props.className : "",
216
+ value: selectedValue
217
+ },
218
+ props.options && props.options.map((option) => /* @__PURE__ */ import_react6.default.createElement(
219
+ import_antd6.Radio,
220
+ {
221
+ key: option.value,
222
+ value: option.value,
223
+ disabled: isDisabled && selectedValue !== option.value,
224
+ className: getButtonStyle(option),
225
+ style: { pointerEvents: isDisabled && selectedValue !== option.value ? "none" : "auto" }
226
+ },
227
+ option.label
228
+ ))
229
+ );
199
230
  };
200
231
 
201
232
  // src/Components/Checkbox.tsx
@@ -356,64 +387,141 @@ var MultipleSelectElement = (props) => {
356
387
  // src/Components/Button.tsx
357
388
  var import_react12 = __toESM(require("react"));
358
389
  var import_antd10 = require("antd");
359
- var ButtonElement = () => /* @__PURE__ */ import_react12.default.createElement(import_antd10.Flex, { gap: "small" }, /* @__PURE__ */ import_react12.default.createElement(import_antd10.Button, { type: "primary" }, "Primary Button"));
390
+ var ButtonElement = (props) => {
391
+ const handleClick = typeof props.action === "string" ? () => {
392
+ console.log("Performing action:", props.action);
393
+ } : props.action;
394
+ return /* @__PURE__ */ import_react12.default.createElement(import_antd10.Flex, null, /* @__PURE__ */ import_react12.default.createElement(import_antd10.Button, { onClick: handleClick, className: props.className }, props.label));
395
+ };
360
396
 
361
397
  // src/Components/AddMoreTable.tsx
362
398
  var import_react13 = __toESM(require("react"));
363
399
  var import_antd11 = require("antd");
400
+ var import_icons2 = require("@ant-design/icons");
364
401
  var AddMoreTable = (props) => {
365
402
  const { thead, tbody } = props;
366
- const [tableData, setTableData] = (0, import_react13.useState)({});
367
- const onHandleChange = (name, value) => {
368
- setTableData((prev) => ({ ...prev, [name]: value }));
369
- console.log(tableData);
403
+ const [rows, setRows] = (0, import_react13.useState)(tbody || []);
404
+ const onHandleRows = () => {
405
+ const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
406
+ let newRow = {
407
+ id: newId,
408
+ label: "Medicine",
409
+ name: "Medicine",
410
+ type: "text",
411
+ variable_data: [
412
+ {
413
+ id: 1,
414
+ Route: { label: "Route", element: "single-select", type: "text" },
415
+ Dose: { label: "Dose", element: "single-select", type: "text" },
416
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
417
+ When: { label: "When", element: "textarea", type: "text" },
418
+ Duration: { label: "Duration", element: "textarea", type: "text" },
419
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
420
+ SubRows: { delete: "delete", add: "plus" }
421
+ }
422
+ ]
423
+ };
424
+ setRows((prevData) => [...prevData, newRow]);
370
425
  };
371
- const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
372
- title: eachHeadEl.label,
373
- dataIndex: eachHeadEl.name,
374
- key: eachHeadEl.id
375
- })) : [];
376
- const renderInputElement = (element) => {
426
+ const onHandleDelete = (id) => {
427
+ setRows((prevRows) => prevRows.filter((row) => row.id !== id));
428
+ };
429
+ const onHandleSubRowsAdd = (rowIndex) => {
430
+ setRows((prevRows) => {
431
+ return prevRows.map((row, index) => {
432
+ if (index === rowIndex) {
433
+ const newSubRow = {
434
+ id: row.variable_data.length + 1,
435
+ Route: { label: "Route", element: "single-select", type: "text" },
436
+ Dose: { label: "Dose", element: "single-select", type: "text" },
437
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
438
+ When: { label: "When", element: "textarea", type: "text" },
439
+ Duration: { label: "Duration", element: "textarea", type: "text" },
440
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
441
+ SubRows: { delete: "delete", add: "plus" }
442
+ };
443
+ const updatedVariableData = [...row.variable_data, newSubRow];
444
+ return {
445
+ ...row,
446
+ variable_data: updatedVariableData
447
+ };
448
+ }
449
+ return row;
450
+ });
451
+ });
452
+ };
453
+ const onHandleSubRowsDelete = (rowIndex, subIndex) => {
454
+ setRows((prevRows) => {
455
+ return prevRows.map((row, index) => {
456
+ if (index === rowIndex) {
457
+ const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
458
+ return {
459
+ ...row,
460
+ variable_data: updatedVariableData
461
+ };
462
+ }
463
+ return row;
464
+ });
465
+ });
466
+ };
467
+ (0, import_react13.useEffect)(() => {
468
+ console.log(rows);
469
+ }, [rows]);
470
+ const renderInputElement = (element, value) => {
471
+ if (!element)
472
+ return null;
377
473
  const { element: type, label } = element;
378
- console.log("type....", type);
379
474
  if (type === "single-select") {
380
- return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
475
+ return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0 });
381
476
  } else if (type === "textarea") {
382
- return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
477
+ return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0 });
383
478
  } else {
384
479
  return null;
385
480
  }
386
481
  };
387
- const dataSource = tbody && tbody.length > 0 ? tbody.map((eachRow, index) => {
388
- const rowElements = {};
389
- if (eachRow.element && eachRow.label) {
390
- rowElements[eachRow.id] = String(index);
391
- rowElements[eachRow.label] = renderInputElement(eachRow);
392
- }
393
- const variableData = eachRow.variable_data && Array.isArray(eachRow.variable_data) ? eachRow.variable_data.reduce((acc, curr) => {
394
- if (!curr.label || !curr.element) {
395
- console.error(`Invalid element in row ${index}:`, curr);
396
- return acc;
397
- }
398
- acc[curr.label] = renderInputElement(curr);
399
- return acc;
400
- }, {}) : {};
401
- return {
402
- key: index.toString(),
403
- ...eachRow,
404
- ...rowElements,
405
- ...variableData
482
+ const dataSource = rows.map((eachRow, rowIndex) => {
483
+ const rowData = {
484
+ key: eachRow.id,
485
+ "#": rowIndex + 1,
486
+ "Medicine": renderInputElement({
487
+ element: eachRow.element,
488
+ label: eachRow.label
489
+ })
406
490
  };
407
- }) : [];
408
- console.log("dataSource.........", dataSource);
409
- return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
491
+ rowData["Medicine"] = renderInputElement(eachRow.variable_data[0].Medicine);
492
+ eachRow.variable_data.map((variable, subIndex) => {
493
+ Object.keys(variable).forEach((key) => {
494
+ if (key === "SubRows") {
495
+ rowData[`${key}`] = /* @__PURE__ */ import_react13.default.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleSubRowsDelete(rowIndex, subIndex) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleSubRowsAdd(rowIndex) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
496
+ } else {
497
+ rowData[`${key}`] = renderInputElement(variable[key]);
498
+ }
499
+ });
500
+ });
501
+ rowData.actions = /* @__PURE__ */ import_react13.default.createElement("div", null, /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.DeleteOutlined, null)), rowIndex === rows.length - 1 && /* @__PURE__ */ import_react13.default.createElement(import_antd11.Button, { onClick: onHandleRows }, /* @__PURE__ */ import_react13.default.createElement(import_icons2.PlusOutlined, null)));
502
+ return rowData;
503
+ });
504
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
505
+ title: eachHeadEl.label,
506
+ dataIndex: eachHeadEl.name,
507
+ key: eachHeadEl.id
508
+ })) : [];
509
+ if (!columns.some((col) => col.dataIndex === "actions")) {
510
+ columns.push({
511
+ title: "Actions",
512
+ dataIndex: "actions",
513
+ key: "actions"
514
+ });
515
+ }
516
+ return /* @__PURE__ */ import_react13.default.createElement(
410
517
  import_antd11.Table,
411
518
  {
412
519
  columns,
413
- expandable: { defaultExpandedRowKeys: ["0"] },
414
- dataSource
520
+ dataSource,
521
+ pagination: false,
522
+ bordered: true
415
523
  }
416
- ));
524
+ );
417
525
  };
418
526
  // Annotate the CommonJS export names for ESM import in node:
419
527
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -68,7 +68,6 @@ var NumberElement = (props) => {
68
68
  prefix: props.prefix,
69
69
  type: props.type,
70
70
  status: props.status,
71
- style: props.styles,
72
71
  className: props.classNames,
73
72
  variant: props.variant,
74
73
  name: props.name,
@@ -91,7 +90,6 @@ var TextareaElement = (props) => {
91
90
  disabled: props.disabled,
92
91
  id: props.name,
93
92
  status: props.status,
94
- style: props.styles,
95
93
  className: props.classNames,
96
94
  variant: props.variant,
97
95
  name: props.name,
@@ -138,27 +136,60 @@ var SelectElement = (props) => {
138
136
  };
139
137
 
140
138
  // src/Components/RadioElement.tsx
141
- import React6 from "react";
139
+ import React6, { useState as useState2, useEffect } from "react";
142
140
  import { Radio } from "antd";
143
141
  var RadioElement = (props) => {
142
+ const [isDisabled, setIsDisabled] = useState2(props.disabled);
143
+ const [selectedValue, setSelectedValue] = useState2(props.value);
144
+ let optionType;
145
+ if (props.optionType === "button") {
146
+ optionType = props.optionType;
147
+ }
148
+ useEffect(() => {
149
+ setIsDisabled(props.disabled);
150
+ }, [props.disabled]);
144
151
  const handleChange = (e) => {
152
+ const selectedVal = e.target.value;
153
+ const selectedOptions = [{ id: selectedVal, value: selectedVal }];
154
+ setSelectedValue(selectedVal);
155
+ setIsDisabled(true);
145
156
  if (props.onChange) {
146
- const selectedVal = e.target.value;
147
- const selectedOptions = [{ id: selectedVal, value: selectedVal }];
148
157
  props.onChange(selectedOptions);
149
158
  }
150
159
  };
151
- return /* @__PURE__ */ React6.createElement(Radio.Group, { name: "radiogroup", defaultValue: 1 }, /* @__PURE__ */ React6.createElement(Radio, { value: 1, onChange: handleChange }, "A"), /* @__PURE__ */ React6.createElement(Radio, { value: 2, onChange: handleChange }, "B"), /* @__PURE__ */ React6.createElement(Radio, { value: 3, onChange: handleChange }, "C"), /* @__PURE__ */ React6.createElement(Radio, { value: 4, onChange: handleChange }, "D"));
160
+ const getButtonStyle = (option) => {
161
+ return selectedValue === option.value ? option.selectedClassName : option.className;
162
+ };
163
+ return /* @__PURE__ */ React6.createElement(
164
+ Radio.Group,
165
+ {
166
+ onChange: handleChange,
167
+ optionType,
168
+ className: props.className ? props.className : "",
169
+ value: selectedValue
170
+ },
171
+ props.options && props.options.map((option) => /* @__PURE__ */ React6.createElement(
172
+ Radio,
173
+ {
174
+ key: option.value,
175
+ value: option.value,
176
+ disabled: isDisabled && selectedValue !== option.value,
177
+ className: getButtonStyle(option),
178
+ style: { pointerEvents: isDisabled && selectedValue !== option.value ? "none" : "auto" }
179
+ },
180
+ option.label
181
+ ))
182
+ );
152
183
  };
153
184
 
154
185
  // src/Components/Checkbox.tsx
155
- import React7, { useState as useState2 } from "react";
186
+ import React7, { useState as useState3 } from "react";
156
187
  import { Checkbox, Divider } from "antd";
157
188
  var CheckboxGroup = Checkbox.Group;
158
189
  var plainOptions = ["Apple", "Pear", "Orange"];
159
190
  var defaultCheckedList = [];
160
191
  var CheckboxElement = (props) => {
161
- const [checkedList, setCheckedList] = useState2(defaultCheckedList);
192
+ const [checkedList, setCheckedList] = useState3(defaultCheckedList);
162
193
  const checkAll = plainOptions.length === checkedList.length;
163
194
  const handleChange = (list) => {
164
195
  setCheckedList(list);
@@ -309,64 +340,141 @@ var MultipleSelectElement = (props) => {
309
340
  // src/Components/Button.tsx
310
341
  import React11 from "react";
311
342
  import { Button as Button2, Flex as Flex2 } from "antd";
312
- var ButtonElement = () => /* @__PURE__ */ React11.createElement(Flex2, { gap: "small" }, /* @__PURE__ */ React11.createElement(Button2, { type: "primary" }, "Primary Button"));
343
+ var ButtonElement = (props) => {
344
+ const handleClick = typeof props.action === "string" ? () => {
345
+ console.log("Performing action:", props.action);
346
+ } : props.action;
347
+ return /* @__PURE__ */ React11.createElement(Flex2, null, /* @__PURE__ */ React11.createElement(Button2, { onClick: handleClick, className: props.className }, props.label));
348
+ };
313
349
 
314
350
  // src/Components/AddMoreTable.tsx
315
- import React12, { useState as useState3 } from "react";
316
- import { Table } from "antd";
351
+ import React12, { useEffect as useEffect2, useState as useState4 } from "react";
352
+ import { Table, Button as Button3 } from "antd";
353
+ import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
317
354
  var AddMoreTable = (props) => {
318
355
  const { thead, tbody } = props;
319
- const [tableData, setTableData] = useState3({});
320
- const onHandleChange = (name, value) => {
321
- setTableData((prev) => ({ ...prev, [name]: value }));
322
- console.log(tableData);
356
+ const [rows, setRows] = useState4(tbody || []);
357
+ const onHandleRows = () => {
358
+ const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
359
+ let newRow = {
360
+ id: newId,
361
+ label: "Medicine",
362
+ name: "Medicine",
363
+ type: "text",
364
+ variable_data: [
365
+ {
366
+ id: 1,
367
+ Route: { label: "Route", element: "single-select", type: "text" },
368
+ Dose: { label: "Dose", element: "single-select", type: "text" },
369
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
370
+ When: { label: "When", element: "textarea", type: "text" },
371
+ Duration: { label: "Duration", element: "textarea", type: "text" },
372
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
373
+ SubRows: { delete: "delete", add: "plus" }
374
+ }
375
+ ]
376
+ };
377
+ setRows((prevData) => [...prevData, newRow]);
323
378
  };
324
- const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
325
- title: eachHeadEl.label,
326
- dataIndex: eachHeadEl.name,
327
- key: eachHeadEl.id
328
- })) : [];
329
- const renderInputElement = (element) => {
379
+ const onHandleDelete = (id) => {
380
+ setRows((prevRows) => prevRows.filter((row) => row.id !== id));
381
+ };
382
+ const onHandleSubRowsAdd = (rowIndex) => {
383
+ setRows((prevRows) => {
384
+ return prevRows.map((row, index) => {
385
+ if (index === rowIndex) {
386
+ const newSubRow = {
387
+ id: row.variable_data.length + 1,
388
+ Route: { label: "Route", element: "single-select", type: "text" },
389
+ Dose: { label: "Dose", element: "single-select", type: "text" },
390
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
391
+ When: { label: "When", element: "textarea", type: "text" },
392
+ Duration: { label: "Duration", element: "textarea", type: "text" },
393
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
394
+ SubRows: { delete: "delete", add: "plus" }
395
+ };
396
+ const updatedVariableData = [...row.variable_data, newSubRow];
397
+ return {
398
+ ...row,
399
+ variable_data: updatedVariableData
400
+ };
401
+ }
402
+ return row;
403
+ });
404
+ });
405
+ };
406
+ const onHandleSubRowsDelete = (rowIndex, subIndex) => {
407
+ setRows((prevRows) => {
408
+ return prevRows.map((row, index) => {
409
+ if (index === rowIndex) {
410
+ const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
411
+ return {
412
+ ...row,
413
+ variable_data: updatedVariableData
414
+ };
415
+ }
416
+ return row;
417
+ });
418
+ });
419
+ };
420
+ useEffect2(() => {
421
+ console.log(rows);
422
+ }, [rows]);
423
+ const renderInputElement = (element, value) => {
424
+ if (!element)
425
+ return null;
330
426
  const { element: type, label } = element;
331
- console.log("type....", type);
332
427
  if (type === "single-select") {
333
- return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
428
+ return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0 });
334
429
  } else if (type === "textarea") {
335
- return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
430
+ return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0 });
336
431
  } else {
337
432
  return null;
338
433
  }
339
434
  };
340
- const dataSource = tbody && tbody.length > 0 ? tbody.map((eachRow, index) => {
341
- const rowElements = {};
342
- if (eachRow.element && eachRow.label) {
343
- rowElements[eachRow.id] = String(index);
344
- rowElements[eachRow.label] = renderInputElement(eachRow);
345
- }
346
- const variableData = eachRow.variable_data && Array.isArray(eachRow.variable_data) ? eachRow.variable_data.reduce((acc, curr) => {
347
- if (!curr.label || !curr.element) {
348
- console.error(`Invalid element in row ${index}:`, curr);
349
- return acc;
350
- }
351
- acc[curr.label] = renderInputElement(curr);
352
- return acc;
353
- }, {}) : {};
354
- return {
355
- key: index.toString(),
356
- ...eachRow,
357
- ...rowElements,
358
- ...variableData
435
+ const dataSource = rows.map((eachRow, rowIndex) => {
436
+ const rowData = {
437
+ key: eachRow.id,
438
+ "#": rowIndex + 1,
439
+ "Medicine": renderInputElement({
440
+ element: eachRow.element,
441
+ label: eachRow.label
442
+ })
359
443
  };
360
- }) : [];
361
- console.log("dataSource.........", dataSource);
362
- return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
444
+ rowData["Medicine"] = renderInputElement(eachRow.variable_data[0].Medicine);
445
+ eachRow.variable_data.map((variable, subIndex) => {
446
+ Object.keys(variable).forEach((key) => {
447
+ if (key === "SubRows") {
448
+ rowData[`${key}`] = /* @__PURE__ */ React12.createElement("div", { key: subIndex }, eachRow.variable_data.length > 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsDelete(rowIndex, subIndex) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), subIndex === eachRow.variable_data.length - 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleSubRowsAdd(rowIndex) }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
449
+ } else {
450
+ rowData[`${key}`] = renderInputElement(variable[key]);
451
+ }
452
+ });
453
+ });
454
+ rowData.actions = /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(Button3, { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), rowIndex === rows.length - 1 && /* @__PURE__ */ React12.createElement(Button3, { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)));
455
+ return rowData;
456
+ });
457
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
458
+ title: eachHeadEl.label,
459
+ dataIndex: eachHeadEl.name,
460
+ key: eachHeadEl.id
461
+ })) : [];
462
+ if (!columns.some((col) => col.dataIndex === "actions")) {
463
+ columns.push({
464
+ title: "Actions",
465
+ dataIndex: "actions",
466
+ key: "actions"
467
+ });
468
+ }
469
+ return /* @__PURE__ */ React12.createElement(
363
470
  Table,
364
471
  {
365
472
  columns,
366
- expandable: { defaultExpandedRowKeys: ["0"] },
367
- dataSource
473
+ dataSource,
474
+ pagination: false,
475
+ bordered: true
368
476
  }
369
- ));
477
+ );
370
478
  };
371
479
  export {
372
480
  AddMoreTable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.12-Beta3",
3
+ "version": "0.0.12-Beta30",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",