@apexcura/ui-components 0.0.11-Beta10 → 0.0.11-Beta101

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
@@ -7,7 +7,7 @@ type ElementType = {
7
7
  disabled?: boolean;
8
8
  prefix?: React.ReactNode;
9
9
  type?: string;
10
- value?: string | number | boolean | any[];
10
+ value?: string | number | boolean | any[] | null;
11
11
  status?: "error" | "warning";
12
12
  styles?: React.CSSProperties;
13
13
  classNames?: string;
@@ -17,11 +17,15 @@ type ElementType = {
17
17
  suffix?: React.ReactNode;
18
18
  maxLength?: number;
19
19
  fieldNames?: any[];
20
+ options?: any[];
20
21
  onChange?: (value: string | number | boolean | any[]) => void;
21
22
  dropDownOptions?: any[];
22
23
  id?: number;
23
24
  thead?: any[];
24
25
  tbody?: any[];
26
+ variable_data?: any[];
27
+ optionType?: string;
28
+ selectedClassName?: string;
25
29
  };
26
30
 
27
31
  interface ElementExecuterProps$3 extends ElementType {
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ type ElementType = {
7
7
  disabled?: boolean;
8
8
  prefix?: React.ReactNode;
9
9
  type?: string;
10
- value?: string | number | boolean | any[];
10
+ value?: string | number | boolean | any[] | null;
11
11
  status?: "error" | "warning";
12
12
  styles?: React.CSSProperties;
13
13
  classNames?: string;
@@ -17,11 +17,15 @@ type ElementType = {
17
17
  suffix?: React.ReactNode;
18
18
  maxLength?: number;
19
19
  fieldNames?: any[];
20
+ options?: any[];
20
21
  onChange?: (value: string | number | boolean | any[]) => void;
21
22
  dropDownOptions?: any[];
22
23
  id?: number;
23
24
  thead?: any[];
24
25
  tbody?: any[];
26
+ variable_data?: any[];
27
+ optionType?: string;
28
+ selectedClassName?: string;
25
29
  };
26
30
 
27
31
  interface ElementExecuterProps$3 extends ElementType {
package/dist/index.js CHANGED
@@ -188,14 +188,24 @@ var SelectElement = (props) => {
188
188
  var import_react6 = __toESM(require("react"));
189
189
  var import_antd6 = require("antd");
190
190
  var RadioElement = (props) => {
191
+ const [isDisabled, setIsDisabled] = (0, import_react6.useState)(props.disabled);
191
192
  const handleChange = (e) => {
192
193
  if (props.onChange) {
193
194
  const selectedVal = e.target.value;
194
195
  const selectedOptions = [{ id: selectedVal, value: selectedVal }];
195
196
  props.onChange(selectedOptions);
197
+ setIsDisabled(true);
196
198
  }
197
199
  };
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"));
200
+ return /* @__PURE__ */ import_react6.default.createElement(
201
+ import_antd6.Radio.Group,
202
+ {
203
+ options: props.options,
204
+ onChange: handleChange,
205
+ disabled: isDisabled,
206
+ optionType: "button"
207
+ }
208
+ );
199
209
  };
200
210
 
201
211
  // src/Components/Checkbox.tsx
@@ -361,49 +371,131 @@ var ButtonElement = () => /* @__PURE__ */ import_react12.default.createElement(i
361
371
  // src/Components/AddMoreTable.tsx
362
372
  var import_react13 = __toESM(require("react"));
363
373
  var import_antd11 = require("antd");
374
+ var import_icons2 = require("@ant-design/icons");
364
375
  var AddMoreTable = (props) => {
365
376
  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);
377
+ const [rows, setRows] = (0, import_react13.useState)(tbody || []);
378
+ const onHandleRows = () => {
379
+ const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
380
+ let newRow = {
381
+ id: newId,
382
+ label: "Medicine",
383
+ name: "Medicine",
384
+ type: "text",
385
+ variable_data: [
386
+ {
387
+ id: 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
+ ]
397
+ };
398
+ setRows((prevData) => [...prevData, newRow]);
370
399
  };
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) => {
377
- const { type, label } = element;
400
+ const onHandleDelete = (id) => {
401
+ setRows((prevRows) => prevRows.filter((row) => row.id !== id));
402
+ };
403
+ const onHandleSubRowsAdd = (rowIndex) => {
404
+ setRows((prevRows) => {
405
+ return prevRows.map((row, index) => {
406
+ if (index === rowIndex) {
407
+ const newSubRow = {
408
+ id: row.variable_data.length + 1,
409
+ Route: { label: "Route", element: "single-select", type: "text" },
410
+ Dose: { label: "Dose", element: "single-select", type: "text" },
411
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
412
+ When: { label: "When", element: "textarea", type: "text" },
413
+ Duration: { label: "Duration", element: "textarea", type: "text" },
414
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
415
+ SubRows: { delete: "delete", add: "plus" }
416
+ };
417
+ const updatedVariableData = [...row.variable_data, newSubRow];
418
+ return {
419
+ ...row,
420
+ variable_data: updatedVariableData
421
+ };
422
+ }
423
+ return row;
424
+ });
425
+ });
426
+ };
427
+ const onHandleSubRowsDelete = (rowIndex, subIndex) => {
428
+ setRows((prevRows) => {
429
+ return prevRows.map((row, index) => {
430
+ if (index === rowIndex) {
431
+ const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
432
+ return {
433
+ ...row,
434
+ variable_data: updatedVariableData
435
+ };
436
+ }
437
+ return row;
438
+ });
439
+ });
440
+ };
441
+ (0, import_react13.useEffect)(() => {
442
+ console.log(rows);
443
+ }, [rows]);
444
+ const renderInputElement = (element, value) => {
445
+ if (!element)
446
+ return null;
447
+ const { element: type, label } = element;
378
448
  if (type === "single-select") {
379
- return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
449
+ return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "" });
380
450
  } else if (type === "textarea") {
381
- return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
451
+ return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "" });
382
452
  } else {
383
453
  return null;
384
454
  }
385
455
  };
386
- const dataSource = tbody && tbody.length > 0 ? tbody.map((eachRow, index) => {
387
- const variableData = eachRow.variable_data.reduce((acc, curr) => {
388
- acc[curr.label] = renderInputElement(curr);
389
- console.log("acc", acc);
390
- return acc;
391
- }, {});
392
- return {
393
- key: index.toString(),
394
- ...eachRow,
395
- ...variableData
456
+ const dataSource = rows.map((eachRow, rowIndex) => {
457
+ const rowData = {
458
+ key: eachRow.id,
459
+ "#": rowIndex + 1,
460
+ "Medicine": renderInputElement({
461
+ element: eachRow.element,
462
+ label: eachRow.label
463
+ })
396
464
  };
397
- }) : [];
398
- console.log("dataSource.........", dataSource);
399
- return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
465
+ rowData["Medicine"] = renderInputElement(eachRow.variable_data[0].Medicine);
466
+ eachRow.variable_data.map((variable, subIndex) => {
467
+ Object.keys(variable).forEach((key) => {
468
+ if (key === "SubRows") {
469
+ 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)));
470
+ } else {
471
+ rowData[`${key}`] = renderInputElement(variable[key]);
472
+ }
473
+ });
474
+ });
475
+ 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)));
476
+ return rowData;
477
+ });
478
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
479
+ title: eachHeadEl.label,
480
+ dataIndex: eachHeadEl.name,
481
+ key: eachHeadEl.id
482
+ })) : [];
483
+ if (!columns.some((col) => col.dataIndex === "actions")) {
484
+ columns.push({
485
+ title: "Actions",
486
+ dataIndex: "actions",
487
+ key: "actions"
488
+ });
489
+ }
490
+ return /* @__PURE__ */ import_react13.default.createElement(
400
491
  import_antd11.Table,
401
492
  {
402
493
  columns,
403
- expandable: { defaultExpandedRowKeys: ["0"] },
404
- dataSource
494
+ dataSource,
495
+ pagination: false,
496
+ bordered: true
405
497
  }
406
- ));
498
+ );
407
499
  };
408
500
  // Annotate the CommonJS export names for ESM import in node:
409
501
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -138,27 +138,37 @@ var SelectElement = (props) => {
138
138
  };
139
139
 
140
140
  // src/Components/RadioElement.tsx
141
- import React6 from "react";
141
+ import React6, { useState as useState2 } from "react";
142
142
  import { Radio } from "antd";
143
143
  var RadioElement = (props) => {
144
+ const [isDisabled, setIsDisabled] = useState2(props.disabled);
144
145
  const handleChange = (e) => {
145
146
  if (props.onChange) {
146
147
  const selectedVal = e.target.value;
147
148
  const selectedOptions = [{ id: selectedVal, value: selectedVal }];
148
149
  props.onChange(selectedOptions);
150
+ setIsDisabled(true);
149
151
  }
150
152
  };
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"));
153
+ return /* @__PURE__ */ React6.createElement(
154
+ Radio.Group,
155
+ {
156
+ options: props.options,
157
+ onChange: handleChange,
158
+ disabled: isDisabled,
159
+ optionType: "button"
160
+ }
161
+ );
152
162
  };
153
163
 
154
164
  // src/Components/Checkbox.tsx
155
- import React7, { useState as useState2 } from "react";
165
+ import React7, { useState as useState3 } from "react";
156
166
  import { Checkbox, Divider } from "antd";
157
167
  var CheckboxGroup = Checkbox.Group;
158
168
  var plainOptions = ["Apple", "Pear", "Orange"];
159
169
  var defaultCheckedList = [];
160
170
  var CheckboxElement = (props) => {
161
- const [checkedList, setCheckedList] = useState2(defaultCheckedList);
171
+ const [checkedList, setCheckedList] = useState3(defaultCheckedList);
162
172
  const checkAll = plainOptions.length === checkedList.length;
163
173
  const handleChange = (list) => {
164
174
  setCheckedList(list);
@@ -312,51 +322,133 @@ import { Button as Button2, Flex as Flex2 } from "antd";
312
322
  var ButtonElement = () => /* @__PURE__ */ React11.createElement(Flex2, { gap: "small" }, /* @__PURE__ */ React11.createElement(Button2, { type: "primary" }, "Primary Button"));
313
323
 
314
324
  // src/Components/AddMoreTable.tsx
315
- import React12, { useState as useState3 } from "react";
316
- import { Table } from "antd";
325
+ import React12, { useEffect, useState as useState4 } from "react";
326
+ import { Table, Button as Button3 } from "antd";
327
+ import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
317
328
  var AddMoreTable = (props) => {
318
329
  const { thead, tbody } = props;
319
- const [tableData, setTableData] = useState3({});
320
- const onHandleChange = (name, value) => {
321
- setTableData((prev) => ({ ...prev, [name]: value }));
322
- console.log(tableData);
330
+ const [rows, setRows] = useState4(tbody || []);
331
+ const onHandleRows = () => {
332
+ const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
333
+ let newRow = {
334
+ id: newId,
335
+ label: "Medicine",
336
+ name: "Medicine",
337
+ type: "text",
338
+ variable_data: [
339
+ {
340
+ id: 1,
341
+ Route: { label: "Route", element: "single-select", type: "text" },
342
+ Dose: { label: "Dose", element: "single-select", type: "text" },
343
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
344
+ When: { label: "When", element: "textarea", type: "text" },
345
+ Duration: { label: "Duration", element: "textarea", type: "text" },
346
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
347
+ SubRows: { delete: "delete", add: "plus" }
348
+ }
349
+ ]
350
+ };
351
+ setRows((prevData) => [...prevData, newRow]);
323
352
  };
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) => {
330
- const { type, label } = element;
353
+ const onHandleDelete = (id) => {
354
+ setRows((prevRows) => prevRows.filter((row) => row.id !== id));
355
+ };
356
+ const onHandleSubRowsAdd = (rowIndex) => {
357
+ setRows((prevRows) => {
358
+ return prevRows.map((row, index) => {
359
+ if (index === rowIndex) {
360
+ const newSubRow = {
361
+ id: row.variable_data.length + 1,
362
+ Route: { label: "Route", element: "single-select", type: "text" },
363
+ Dose: { label: "Dose", element: "single-select", type: "text" },
364
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
365
+ When: { label: "When", element: "textarea", type: "text" },
366
+ Duration: { label: "Duration", element: "textarea", type: "text" },
367
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
368
+ SubRows: { delete: "delete", add: "plus" }
369
+ };
370
+ const updatedVariableData = [...row.variable_data, newSubRow];
371
+ return {
372
+ ...row,
373
+ variable_data: updatedVariableData
374
+ };
375
+ }
376
+ return row;
377
+ });
378
+ });
379
+ };
380
+ const onHandleSubRowsDelete = (rowIndex, subIndex) => {
381
+ setRows((prevRows) => {
382
+ return prevRows.map((row, index) => {
383
+ if (index === rowIndex) {
384
+ const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
385
+ return {
386
+ ...row,
387
+ variable_data: updatedVariableData
388
+ };
389
+ }
390
+ return row;
391
+ });
392
+ });
393
+ };
394
+ useEffect(() => {
395
+ console.log(rows);
396
+ }, [rows]);
397
+ const renderInputElement = (element, value) => {
398
+ if (!element)
399
+ return null;
400
+ const { element: type, label } = element;
331
401
  if (type === "single-select") {
332
- return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
402
+ return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "" });
333
403
  } else if (type === "textarea") {
334
- return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
404
+ return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "" });
335
405
  } else {
336
406
  return null;
337
407
  }
338
408
  };
339
- const dataSource = tbody && tbody.length > 0 ? tbody.map((eachRow, index) => {
340
- const variableData = eachRow.variable_data.reduce((acc, curr) => {
341
- acc[curr.label] = renderInputElement(curr);
342
- console.log("acc", acc);
343
- return acc;
344
- }, {});
345
- return {
346
- key: index.toString(),
347
- ...eachRow,
348
- ...variableData
409
+ const dataSource = rows.map((eachRow, rowIndex) => {
410
+ const rowData = {
411
+ key: eachRow.id,
412
+ "#": rowIndex + 1,
413
+ "Medicine": renderInputElement({
414
+ element: eachRow.element,
415
+ label: eachRow.label
416
+ })
349
417
  };
350
- }) : [];
351
- console.log("dataSource.........", dataSource);
352
- return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
418
+ rowData["Medicine"] = renderInputElement(eachRow.variable_data[0].Medicine);
419
+ eachRow.variable_data.map((variable, subIndex) => {
420
+ Object.keys(variable).forEach((key) => {
421
+ if (key === "SubRows") {
422
+ 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)));
423
+ } else {
424
+ rowData[`${key}`] = renderInputElement(variable[key]);
425
+ }
426
+ });
427
+ });
428
+ 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)));
429
+ return rowData;
430
+ });
431
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
432
+ title: eachHeadEl.label,
433
+ dataIndex: eachHeadEl.name,
434
+ key: eachHeadEl.id
435
+ })) : [];
436
+ if (!columns.some((col) => col.dataIndex === "actions")) {
437
+ columns.push({
438
+ title: "Actions",
439
+ dataIndex: "actions",
440
+ key: "actions"
441
+ });
442
+ }
443
+ return /* @__PURE__ */ React12.createElement(
353
444
  Table,
354
445
  {
355
446
  columns,
356
- expandable: { defaultExpandedRowKeys: ["0"] },
357
- dataSource
447
+ dataSource,
448
+ pagination: false,
449
+ bordered: true
358
450
  }
359
- ));
451
+ );
360
452
  };
361
453
  export {
362
454
  AddMoreTable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta10",
3
+ "version": "0.0.11-Beta101",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",