@apexcura/ui-components 0.0.12-Beta7 → 0.0.12-Beta71

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
@@ -35,10 +35,12 @@ __export(src_exports, {
35
35
  CheckboxElement: () => CheckboxElement,
36
36
  CkEditor: () => CkEditor,
37
37
  MultipleSelectElement: () => MultipleSelectElement,
38
+ Navbar: () => Navbar,
38
39
  NumberElement: () => NumberElement,
39
40
  PasswordElement: () => PasswordElement,
40
41
  RadioElement: () => RadioElement,
41
42
  SelectElement: () => SelectElement,
43
+ Sidebar: () => Sidebar,
42
44
  SingleSelectElement: () => SingleSelectElement,
43
45
  TextElement: () => TextElement,
44
46
  TextareaElement: () => TextareaElement
@@ -62,7 +64,7 @@ var TextElement = (props) => {
62
64
  type: props.type,
63
65
  status: props.status,
64
66
  style: props.styles,
65
- className: props.classNames,
67
+ className: props.className,
66
68
  variant: props.variant,
67
69
  name: props.name,
68
70
  onChange: (e) => props.onChange(e.target.value)
@@ -103,7 +105,7 @@ var NumberElement = (props) => {
103
105
  const newValue = e.target.value.replace(/[^0-9]/g, "");
104
106
  props.onChange(newValue);
105
107
  };
106
- return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement("label", { htmlFor: props.name }, props.label), /* @__PURE__ */ import_react3.default.createElement(
108
+ return /* @__PURE__ */ import_react3.default.createElement(
107
109
  import_antd3.Input,
108
110
  {
109
111
  placeholder: props.placeholder,
@@ -115,13 +117,12 @@ var NumberElement = (props) => {
115
117
  prefix: props.prefix,
116
118
  type: props.type,
117
119
  status: props.status,
118
- style: props.styles,
119
- className: props.classNames,
120
+ className: props.className,
120
121
  variant: props.variant,
121
122
  name: props.name,
122
123
  onChange: handleInputChange
123
124
  }
124
- ));
125
+ );
125
126
  };
126
127
 
127
128
  // src/Components/TextareaElement.tsx
@@ -129,7 +130,7 @@ var import_react4 = __toESM(require("react"));
129
130
  var import_antd4 = require("antd");
130
131
  var { TextArea } = import_antd4.Input;
131
132
  var TextareaElement = (props) => {
132
- return /* @__PURE__ */ import_react4.default.createElement(import_antd4.Flex, { vertical: true, gap: 32 }, /* @__PURE__ */ import_react4.default.createElement(
133
+ return /* @__PURE__ */ import_react4.default.createElement(import_antd4.Flex, null, /* @__PURE__ */ import_react4.default.createElement(
133
134
  TextArea,
134
135
  {
135
136
  placeholder: props.placeholder,
@@ -138,8 +139,7 @@ var TextareaElement = (props) => {
138
139
  disabled: props.disabled,
139
140
  id: props.name,
140
141
  status: props.status,
141
- style: props.styles,
142
- className: props.classNames,
142
+ className: props.className,
143
143
  variant: props.variant,
144
144
  name: props.name,
145
145
  showCount: true,
@@ -177,7 +177,7 @@ var SelectElement = (props) => {
177
177
  id: props.name,
178
178
  status: props.status,
179
179
  style: props.styles,
180
- className: props.classNames,
180
+ className: props.className,
181
181
  variant: props.variant,
182
182
  onChange: handleChange
183
183
  }
@@ -187,15 +187,46 @@ var SelectElement = (props) => {
187
187
  // src/Components/RadioElement.tsx
188
188
  var import_react6 = __toESM(require("react"));
189
189
  var import_antd6 = require("antd");
190
+ var containerClassName = " ";
191
+ var radioDefaultStyle = "bg-[#F2F2F2] border border-[#919191] rounded-[8px] m-[10px] hover:bg-[#F2F2F2] text-center text-black shadow-[0px_0px_1px_1px_#919191]";
192
+ var radioSelectedDefaultStyle = "bg-[#E2D6F8] border border-[#B8A4DE] rounded-[8px] p-[6px] m-[10px] shadow-[0px_0px_1px_1px_#B8A4DE] text-center text-black shadow-[0px_0px_1px_1px_#919191]";
190
193
  var RadioElement = (props) => {
194
+ const [isDisabled, setIsDisabled] = (0, import_react6.useState)(props.disabled);
195
+ const [selectedValue, setSelectedValue] = (0, import_react6.useState)(props.value);
196
+ const optionType = props.optionType === "button" ? "button" : void 0;
191
197
  const handleChange = (e) => {
198
+ const selectedVal = e.target.value;
199
+ const selectedLabel = e.target.label;
200
+ const selectedOptions = [{ id: selectedLabel, 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 ? `${radioSelectedDefaultStyle} ${option.selectedClassName}` : `${radioDefaultStyle} ${option.className}`;
209
+ };
210
+ return /* @__PURE__ */ import_react6.default.createElement("div", { className: containerClassName }, /* @__PURE__ */ import_react6.default.createElement("p", null, props.label), /* @__PURE__ */ import_react6.default.createElement(
211
+ import_antd6.Radio.Group,
212
+ {
213
+ onChange: handleChange,
214
+ optionType,
215
+ 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
@@ -229,7 +260,7 @@ var CheckboxElement = (props) => {
229
260
  disabled: props.disabled,
230
261
  id: props.name,
231
262
  style: props.styles,
232
- className: props.classNames,
263
+ className: props.className,
233
264
  onChange: onHandleAllChanges,
234
265
  checked: checkAll
235
266
  },
@@ -239,7 +270,7 @@ var CheckboxElement = (props) => {
239
270
  {
240
271
  disabled: props.disabled,
241
272
  style: props.styles,
242
- className: props.classNames,
273
+ className: props.className,
243
274
  options: plainOptions,
244
275
  value: checkedList,
245
276
  onChange: handleChange
@@ -266,8 +297,7 @@ var CkEditor = (props) => {
266
297
  {
267
298
  apiKey: "rwpgt7maa54n0pe5mglhkl686p7h57sg6z636n6gf2mio1b9",
268
299
  onInit: (_evt, editor) => {
269
- if (editor)
270
- editorRef.current = editor;
300
+ if (editor) editorRef.current = editor;
271
301
  },
272
302
  initialValue: "<p>This is the initial content of the editor.</p>",
273
303
  init: {
@@ -356,7 +386,20 @@ var MultipleSelectElement = (props) => {
356
386
  // src/Components/Button.tsx
357
387
  var import_react12 = __toESM(require("react"));
358
388
  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"));
389
+ var defaultClassName = "w-[126px] h-[40px] bg-purple-800 text-white rounded-full shadow-lg submit border-none";
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(
395
+ import_antd10.Button,
396
+ {
397
+ onClick: handleClick,
398
+ className: `${defaultClassName} ${props.className ? props.className : ""}`
399
+ },
400
+ props.label
401
+ );
402
+ };
360
403
 
361
404
  // src/Components/AddMoreTable.tsx
362
405
  var import_react13 = __toESM(require("react"));
@@ -364,81 +407,164 @@ var import_antd11 = require("antd");
364
407
  var import_icons2 = require("@ant-design/icons");
365
408
  var AddMoreTable = (props) => {
366
409
  const { thead, tbody } = props;
367
- const [tableData, setTableData] = (0, import_react13.useState)({});
368
410
  const [rows, setRows] = (0, import_react13.useState)(tbody || []);
369
- function isColumnType(column) {
370
- return column.dataIndex !== void 0;
371
- }
372
- const onHandleChange = (name, value) => {
373
- setTableData((prev) => ({ ...prev, [name]: value }));
374
- console.log(tableData);
375
- };
376
411
  const onHandleRows = () => {
377
- const lastRow = rows[rows.length - 1];
378
- const newId = lastRow ? lastRow.id + 1 : lastRow.id;
379
- const newRow = {
380
- ...lastRow,
381
- id: newId
412
+ const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
413
+ let newRow = {
414
+ id: newId,
415
+ label: "Medicine",
416
+ name: "Medicine",
417
+ type: "text",
418
+ element: "single-select",
419
+ variable_data: [
420
+ {
421
+ id: 1,
422
+ Route: { label: "Route", element: "single-select", type: "text" },
423
+ Dose: { label: "Dose", element: "single-select", type: "text" },
424
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
425
+ When: { label: "When", element: "textarea", type: "text" },
426
+ Duration: { label: "Duration", element: "textarea", type: "text" },
427
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
428
+ SubRows: { delete: "delete", add: "plus" }
429
+ }
430
+ ]
382
431
  };
383
432
  setRows((prevData) => [...prevData, newRow]);
384
433
  };
385
- const onHandleDelete = (index) => {
386
- const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
387
- setRows(remainingRows);
434
+ const onHandleDelete = (id) => {
435
+ setRows((prevRows) => prevRows.filter((row) => row.id !== id));
388
436
  };
389
- const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
390
- title: eachHeadEl.label,
391
- dataIndex: eachHeadEl.name,
392
- key: eachHeadEl.id
393
- })) : [];
394
- const renderInputElement = (element) => {
437
+ const onHandleSubRowsAdd = (rowIndex) => {
438
+ setRows((prevRows) => {
439
+ return prevRows.map((row, index) => {
440
+ if (index === rowIndex) {
441
+ const newSubRow = {
442
+ id: row.variable_data.length + 1,
443
+ Route: { label: "Route", element: "single-select", type: "text" },
444
+ Dose: { label: "Dose", element: "single-select", type: "text" },
445
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
446
+ When: { label: "When", element: "textarea", type: "text" },
447
+ Duration: { label: "Duration", element: "textarea", type: "text" },
448
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
449
+ SubRows: { delete: "delete", add: "plus" }
450
+ };
451
+ const updatedVariableData = [...row.variable_data, newSubRow];
452
+ return {
453
+ ...row,
454
+ variable_data: updatedVariableData
455
+ };
456
+ }
457
+ return row;
458
+ });
459
+ });
460
+ };
461
+ const onHandleSubRowsDelete = (rowIndex, subIndex) => {
462
+ setRows((prevRows) => {
463
+ return prevRows.map((row, index) => {
464
+ if (index === rowIndex) {
465
+ const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
466
+ return {
467
+ ...row,
468
+ variable_data: updatedVariableData
469
+ };
470
+ }
471
+ return row;
472
+ });
473
+ });
474
+ };
475
+ (0, import_react13.useEffect)(() => {
476
+ console.log(rows);
477
+ }, [rows]);
478
+ const renderInputElement = (element, value) => {
479
+ if (!element) return null;
395
480
  const { element: type, label } = element;
396
- console.log("type....", type);
397
481
  if (type === "single-select") {
398
- return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
482
+ return /* @__PURE__ */ import_react13.default.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
399
483
  } else if (type === "textarea") {
400
- return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
484
+ return /* @__PURE__ */ import_react13.default.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
401
485
  } else {
402
486
  return null;
403
487
  }
404
488
  };
405
- const dataSource = rows.map((eachRow, index) => {
406
- const rowElements = {};
407
- if (eachRow.element && eachRow.label) {
408
- rowElements[eachRow.label] = renderInputElement(eachRow);
409
- }
410
- const variableData = eachRow.variable_data && Array.isArray(eachRow.variable_data) ? eachRow.variable_data.reduce((acc, curr) => {
411
- if (!curr.label || !curr.element) {
412
- console.error(`Invalid element in row ${index}:`, curr);
413
- return acc;
414
- }
415
- acc[curr.label] = renderInputElement(curr);
416
- return acc;
417
- }, {}) : {};
418
- return {
419
- key: index.toString(),
420
- "#": index + 1,
421
- ...eachRow,
422
- ...rowElements,
423
- ...variableData,
424
- 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)))
489
+ const dataSource = rows.map((eachRow, rowIndex) => {
490
+ const rowData = {
491
+ key: eachRow.id,
492
+ "#": rowIndex + 1,
493
+ "Medicine": renderInputElement({
494
+ element: eachRow.element,
495
+ label: eachRow.label
496
+ })
425
497
  };
498
+ eachRow.variable_data.forEach((variable, subIndex) => {
499
+ Object.keys(variable).forEach((key) => {
500
+ if (key === "SubRows") {
501
+ 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)));
502
+ } else {
503
+ rowData[`${key}`] = renderInputElement(variable[key]);
504
+ }
505
+ });
506
+ });
507
+ 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)));
508
+ console.log("=====rowdata", rowData);
509
+ return rowData;
426
510
  });
427
- if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
511
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
512
+ title: eachHeadEl.label,
513
+ dataIndex: eachHeadEl.name,
514
+ key: eachHeadEl.id
515
+ })) : [];
516
+ if (!columns.some((col) => col.dataIndex === "actions")) {
428
517
  columns.push({
429
518
  title: "Actions",
430
519
  dataIndex: "actions",
431
520
  key: "actions"
432
521
  });
433
522
  }
434
- return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
523
+ return /* @__PURE__ */ import_react13.default.createElement(
435
524
  import_antd11.Table,
436
525
  {
437
526
  columns,
438
- expandable: { defaultExpandedRowKeys: ["0"] },
439
- dataSource
527
+ dataSource,
528
+ pagination: false,
529
+ bordered: true
440
530
  }
441
- ));
531
+ );
532
+ };
533
+
534
+ // src/Components/Sidebar.tsx
535
+ var import_react14 = __toESM(require("react"));
536
+ var Sidebar = (props) => {
537
+ const handleChange = (item) => {
538
+ if (props.onChange) {
539
+ props.onChange(item);
540
+ }
541
+ };
542
+ return /* @__PURE__ */ import_react14.default.createElement("div", { className: props.className, key: props.name }, /* @__PURE__ */ import_react14.default.createElement("div", null, /* @__PURE__ */ import_react14.default.createElement("img", { src: props.img, alt: "logo" })), /* @__PURE__ */ import_react14.default.createElement("ul", { className: props.listClassName }, props.items?.map((item) => {
543
+ return /* @__PURE__ */ import_react14.default.createElement("li", { onClick: () => {
544
+ handleChange(item);
545
+ }, key: item.label, className: `${props.listItemClassName} ${item.active && props.activeClassName}` }, /* @__PURE__ */ import_react14.default.createElement("span", null, item.icon), /* @__PURE__ */ import_react14.default.createElement("span", null, item.label));
546
+ })));
547
+ };
548
+
549
+ // src/Components/Navbar.tsx
550
+ var import_react17 = __toESM(require("react"));
551
+
552
+ // src/Components/Notofication.tsx
553
+ var import_react15 = __toESM(require("react"));
554
+ var import_antd12 = require("antd");
555
+ var Notification = (props) => /* @__PURE__ */ import_react15.default.createElement(import_antd12.Popover, { className: props.notification.className, content: props.notification.items?.map((eachItem) => {
556
+ return /* @__PURE__ */ import_react15.default.createElement("div", null, /* @__PURE__ */ import_react15.default.createElement("p", null, eachItem.text), /* @__PURE__ */ import_react15.default.createElement("p", null, eachItem.time));
557
+ }), trigger: "focus", placement: "bottomRight" }, /* @__PURE__ */ import_react15.default.createElement(import_antd12.Badge, { count: props.notification.count }, props.notification.icon));
558
+
559
+ // src/Components/Profile.tsx
560
+ var import_react16 = __toESM(require("react"));
561
+ var Profile = (props) => /* @__PURE__ */ import_react16.default.createElement("div", { className: props.profile.className }, /* @__PURE__ */ import_react16.default.createElement("img", { src: props.profile.profileImage, alt: "profile", className: props.profile.profileImageClassName }), /* @__PURE__ */ import_react16.default.createElement("div", { className: props.profile.profileSubClassName }, /* @__PURE__ */ import_react16.default.createElement("span", null, props.profile.primaryText), /* @__PURE__ */ import_react16.default.createElement("span", null, props.profile.secondaryText)));
562
+
563
+ // src/Components/Navbar.tsx
564
+ var Navbar = (props) => {
565
+ const test = "w-full flex justify-between";
566
+ const dashboradClass = "text-xl,text-default-600";
567
+ return /* @__PURE__ */ import_react17.default.createElement("div", { className: `${test} ${props.subContainerClassName}` }, /* @__PURE__ */ import_react17.default.createElement("div", { className: `${dashboradClass} ${props.dashboard.className}` }, props.dashboard.label), /* @__PURE__ */ import_react17.default.createElement("div", { className: "flex" }, /* @__PURE__ */ import_react17.default.createElement(Notification, { ...props }), /* @__PURE__ */ import_react17.default.createElement(Profile, { ...props })));
442
568
  };
443
569
  // Annotate the CommonJS export names for ESM import in node:
444
570
  0 && (module.exports = {
@@ -447,10 +573,12 @@ var AddMoreTable = (props) => {
447
573
  CheckboxElement,
448
574
  CkEditor,
449
575
  MultipleSelectElement,
576
+ Navbar,
450
577
  NumberElement,
451
578
  PasswordElement,
452
579
  RadioElement,
453
580
  SelectElement,
581
+ Sidebar,
454
582
  SingleSelectElement,
455
583
  TextElement,
456
584
  TextareaElement