@apexcura/ui-components 0.0.11-Beta13 → 0.0.11-Beta130

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.mjs CHANGED
@@ -15,7 +15,7 @@ var TextElement = (props) => {
15
15
  type: props.type,
16
16
  status: props.status,
17
17
  style: props.styles,
18
- className: props.classNames,
18
+ className: props.className,
19
19
  variant: props.variant,
20
20
  name: props.name,
21
21
  onChange: (e) => props.onChange(e.target.value)
@@ -56,7 +56,7 @@ var NumberElement = (props) => {
56
56
  const newValue = e.target.value.replace(/[^0-9]/g, "");
57
57
  props.onChange(newValue);
58
58
  };
59
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("label", { htmlFor: props.name }, props.label), /* @__PURE__ */ React3.createElement(
59
+ return /* @__PURE__ */ React3.createElement(
60
60
  AntInput2,
61
61
  {
62
62
  placeholder: props.placeholder,
@@ -68,13 +68,12 @@ var NumberElement = (props) => {
68
68
  prefix: props.prefix,
69
69
  type: props.type,
70
70
  status: props.status,
71
- style: props.styles,
72
- className: props.classNames,
71
+ className: props.className,
73
72
  variant: props.variant,
74
73
  name: props.name,
75
74
  onChange: handleInputChange
76
75
  }
77
- ));
76
+ );
78
77
  };
79
78
 
80
79
  // src/Components/TextareaElement.tsx
@@ -82,7 +81,7 @@ import React4 from "react";
82
81
  import { Flex, Input as Input2 } from "antd";
83
82
  var { TextArea } = Input2;
84
83
  var TextareaElement = (props) => {
85
- return /* @__PURE__ */ React4.createElement(Flex, { vertical: true, gap: 32 }, /* @__PURE__ */ React4.createElement(
84
+ return /* @__PURE__ */ React4.createElement(Flex, null, /* @__PURE__ */ React4.createElement(
86
85
  TextArea,
87
86
  {
88
87
  placeholder: props.placeholder,
@@ -91,8 +90,7 @@ var TextareaElement = (props) => {
91
90
  disabled: props.disabled,
92
91
  id: props.name,
93
92
  status: props.status,
94
- style: props.styles,
95
- className: props.classNames,
93
+ className: props.className,
96
94
  variant: props.variant,
97
95
  name: props.name,
98
96
  showCount: true,
@@ -130,7 +128,7 @@ var SelectElement = (props) => {
130
128
  id: props.name,
131
129
  status: props.status,
132
130
  style: props.styles,
133
- className: props.classNames,
131
+ className: props.className,
134
132
  variant: props.variant,
135
133
  onChange: handleChange
136
134
  }
@@ -138,27 +136,57 @@ var SelectElement = (props) => {
138
136
  };
139
137
 
140
138
  // src/Components/RadioElement.tsx
141
- import React6 from "react";
139
+ import React6, { useState as useState2 } from "react";
142
140
  import { Radio } from "antd";
141
+ var containerClassName = " ";
142
+ var className = "bg-[#F2F2F2] border border-[#919191] !rounded-[8px] !m-[10px] hover:bg-[#F2F2F2] !text-center !text-black !shadow-[0px_0px_1px_1px_#919191]";
143
+ var selectedClassName = "!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]";
143
144
  var RadioElement = (props) => {
145
+ const [isDisabled, setIsDisabled] = useState2(props.disabled);
146
+ const [selectedValue, setSelectedValue] = useState2(props.value);
147
+ const optionType = props.optionType === "button" ? "button" : void 0;
144
148
  const handleChange = (e) => {
149
+ const selectedVal = e.target.value;
150
+ const selectedOptions = [{ id: selectedVal, value: selectedVal }];
151
+ setSelectedValue(selectedVal);
152
+ setIsDisabled(true);
145
153
  if (props.onChange) {
146
- const selectedVal = e.target.value;
147
- const selectedOptions = [{ id: selectedVal, value: selectedVal }];
148
154
  props.onChange(selectedOptions);
149
155
  }
150
156
  };
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"));
157
+ const getButtonStyle = (option) => {
158
+ return selectedValue === option.value ? `${selectedClassName} ${option.selectedClassName}` : `${className} ${option.className}`;
159
+ };
160
+ return /* @__PURE__ */ React6.createElement("div", { className: containerClassName }, /* @__PURE__ */ React6.createElement("p", null, props.label), /* @__PURE__ */ React6.createElement(
161
+ Radio.Group,
162
+ {
163
+ onChange: handleChange,
164
+ optionType,
165
+ className: props.className,
166
+ value: selectedValue
167
+ },
168
+ props.options && props.options.map((option) => /* @__PURE__ */ React6.createElement(
169
+ Radio,
170
+ {
171
+ key: option.value,
172
+ value: option.value,
173
+ disabled: isDisabled && selectedValue !== option.value,
174
+ className: getButtonStyle(option),
175
+ style: { pointerEvents: isDisabled && selectedValue !== option.value ? "none" : "auto" }
176
+ },
177
+ option.label
178
+ ))
179
+ ));
152
180
  };
153
181
 
154
182
  // src/Components/Checkbox.tsx
155
- import React7, { useState as useState2 } from "react";
183
+ import React7, { useState as useState3 } from "react";
156
184
  import { Checkbox, Divider } from "antd";
157
185
  var CheckboxGroup = Checkbox.Group;
158
186
  var plainOptions = ["Apple", "Pear", "Orange"];
159
187
  var defaultCheckedList = [];
160
188
  var CheckboxElement = (props) => {
161
- const [checkedList, setCheckedList] = useState2(defaultCheckedList);
189
+ const [checkedList, setCheckedList] = useState3(defaultCheckedList);
162
190
  const checkAll = plainOptions.length === checkedList.length;
163
191
  const handleChange = (list) => {
164
192
  setCheckedList(list);
@@ -182,7 +210,7 @@ var CheckboxElement = (props) => {
182
210
  disabled: props.disabled,
183
211
  id: props.name,
184
212
  style: props.styles,
185
- className: props.classNames,
213
+ className: props.className,
186
214
  onChange: onHandleAllChanges,
187
215
  checked: checkAll
188
216
  },
@@ -192,7 +220,7 @@ var CheckboxElement = (props) => {
192
220
  {
193
221
  disabled: props.disabled,
194
222
  style: props.styles,
195
- className: props.classNames,
223
+ className: props.className,
196
224
  options: plainOptions,
197
225
  value: checkedList,
198
226
  onChange: handleChange
@@ -219,8 +247,7 @@ var CkEditor = (props) => {
219
247
  {
220
248
  apiKey: "rwpgt7maa54n0pe5mglhkl686p7h57sg6z636n6gf2mio1b9",
221
249
  onInit: (_evt, editor) => {
222
- if (editor)
223
- editorRef.current = editor;
250
+ if (editor) editorRef.current = editor;
224
251
  },
225
252
  initialValue: "<p>This is the initial content of the editor.</p>",
226
253
  init: {
@@ -308,58 +335,177 @@ var MultipleSelectElement = (props) => {
308
335
 
309
336
  // src/Components/Button.tsx
310
337
  import React11 from "react";
311
- 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"));
338
+ import { Button as Button2 } from "antd";
339
+ var defaultClassName = "w-[126px] h-[40px] bg-purple-800 text-white rounded-full shadow-lg submit border-none";
340
+ var ButtonElement = (props) => {
341
+ const handleClick = typeof props.action === "string" ? () => {
342
+ console.log("Performing action:", props.action);
343
+ } : props.action;
344
+ return /* @__PURE__ */ React11.createElement(
345
+ Button2,
346
+ {
347
+ onClick: handleClick,
348
+ className: `${defaultClassName} ${props.className ? props.className : ""}`
349
+ },
350
+ props.label
351
+ );
352
+ };
313
353
 
314
354
  // src/Components/AddMoreTable.tsx
315
- import React12, { useState as useState3 } from "react";
316
- import { Table } from "antd";
355
+ import React12, { useEffect, useState as useState4 } from "react";
356
+ import { Table, Button as Button3 } from "antd";
357
+ import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
317
358
  var AddMoreTable = (props) => {
318
359
  const { thead, tbody } = props;
319
- const [tableData, setTableData] = useState3({});
320
- console.log("working");
321
- const onHandleChange = (name, value) => {
322
- setTableData((prev) => ({ ...prev, [name]: value }));
323
- console.log(tableData);
360
+ const [rows, setRows] = useState4(tbody || []);
361
+ const onHandleRows = () => {
362
+ const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
363
+ let newRow = {
364
+ id: newId,
365
+ label: "Medicine",
366
+ name: "Medicine",
367
+ type: "text",
368
+ element: "single-select",
369
+ variable_data: [
370
+ {
371
+ id: 1,
372
+ Route: { label: "Route", element: "single-select", type: "text" },
373
+ Dose: { label: "Dose", element: "single-select", type: "text" },
374
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
375
+ When: { label: "When", element: "textarea", type: "text" },
376
+ Duration: { label: "Duration", element: "textarea", type: "text" },
377
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
378
+ SubRows: { delete: "delete", add: "plus" }
379
+ }
380
+ ]
381
+ };
382
+ setRows((prevData) => [...prevData, newRow]);
324
383
  };
325
- const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
326
- title: eachHeadEl.label,
327
- dataIndex: eachHeadEl.name,
328
- key: eachHeadEl.id
329
- })) : [];
330
- const renderInputElement = (element) => {
384
+ const onHandleDelete = (id) => {
385
+ setRows((prevRows) => prevRows.filter((row) => row.id !== id));
386
+ };
387
+ const onHandleSubRowsAdd = (rowIndex) => {
388
+ setRows((prevRows) => {
389
+ return prevRows.map((row, index) => {
390
+ if (index === rowIndex) {
391
+ const newSubRow = {
392
+ id: row.variable_data.length + 1,
393
+ Route: { label: "Route", element: "single-select", type: "text" },
394
+ Dose: { label: "Dose", element: "single-select", type: "text" },
395
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
396
+ When: { label: "When", element: "textarea", type: "text" },
397
+ Duration: { label: "Duration", element: "textarea", type: "text" },
398
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
399
+ SubRows: { delete: "delete", add: "plus" }
400
+ };
401
+ const updatedVariableData = [...row.variable_data, newSubRow];
402
+ return {
403
+ ...row,
404
+ variable_data: updatedVariableData
405
+ };
406
+ }
407
+ return row;
408
+ });
409
+ });
410
+ };
411
+ const onHandleSubRowsDelete = (rowIndex, subIndex) => {
412
+ setRows((prevRows) => {
413
+ return prevRows.map((row, index) => {
414
+ if (index === rowIndex) {
415
+ const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
416
+ return {
417
+ ...row,
418
+ variable_data: updatedVariableData
419
+ };
420
+ }
421
+ return row;
422
+ });
423
+ });
424
+ };
425
+ useEffect(() => {
426
+ console.log(rows);
427
+ }, [rows]);
428
+ const renderInputElement = (element, value) => {
429
+ if (!element) return null;
331
430
  const { element: type, label } = element;
332
- console.log("type....", type);
333
431
  if (type === "single-select") {
334
- return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
432
+ return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
335
433
  } else if (type === "textarea") {
336
- return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
434
+ return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
337
435
  } else {
338
436
  return null;
339
437
  }
340
438
  };
341
- const dataSource = tbody && tbody.length > 0 ? tbody.map((eachRow, index) => {
342
- const variableData = eachRow.variable_data.reduce((acc, curr) => {
343
- console.log("curr", curr);
344
- acc[curr.label] = renderInputElement(curr);
345
- console.log("....acc", acc);
346
- return acc;
347
- }, {});
348
- return {
349
- key: index.toString(),
350
- ...eachRow,
351
- ...variableData
439
+ const dataSource = rows.map((eachRow, rowIndex) => {
440
+ const rowData = {
441
+ key: eachRow.id,
442
+ "#": rowIndex + 1,
443
+ "Medicine": renderInputElement({
444
+ element: eachRow.element,
445
+ label: eachRow.label
446
+ })
352
447
  };
353
- }) : [];
354
- console.log("dataSource.........", dataSource);
355
- return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
448
+ eachRow.variable_data.forEach((variable, subIndex) => {
449
+ Object.keys(variable).forEach((key) => {
450
+ if (key === "SubRows") {
451
+ 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)));
452
+ } else {
453
+ rowData[`${key}`] = renderInputElement(variable[key]);
454
+ }
455
+ });
456
+ });
457
+ 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)));
458
+ console.log("=====rowdata", rowData);
459
+ return rowData;
460
+ });
461
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
462
+ title: eachHeadEl.label,
463
+ dataIndex: eachHeadEl.name,
464
+ key: eachHeadEl.id
465
+ })) : [];
466
+ if (!columns.some((col) => col.dataIndex === "actions")) {
467
+ columns.push({
468
+ title: "Actions",
469
+ dataIndex: "actions",
470
+ key: "actions"
471
+ });
472
+ }
473
+ return /* @__PURE__ */ React12.createElement(
356
474
  Table,
357
475
  {
358
476
  columns,
359
- expandable: { defaultExpandedRowKeys: ["0"] },
360
- dataSource
477
+ dataSource,
478
+ pagination: false,
479
+ bordered: true
361
480
  }
362
- ));
481
+ );
482
+ };
483
+
484
+ // src/Components/Sidebar.tsx
485
+ import React13 from "react";
486
+ var Sidebar = (props) => {
487
+ return /* @__PURE__ */ React13.createElement("div", { className: props.className }, /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("img", { src: props.img, alt: "logo" })), /* @__PURE__ */ React13.createElement("ul", { className: props.listClassName }, props.items?.map((item) => {
488
+ return /* @__PURE__ */ React13.createElement("li", { key: item.label, className: props.listItemClassName }, /* @__PURE__ */ React13.createElement("span", null, item.icon), /* @__PURE__ */ React13.createElement("span", null, item.label));
489
+ })));
490
+ };
491
+
492
+ // src/Components/Navbar.tsx
493
+ import React16 from "react";
494
+
495
+ // src/Components/Notofication.tsx
496
+ import React14 from "react";
497
+ import { Button as Button4, Popover } from "antd";
498
+ var Notification = (props) => /* @__PURE__ */ React14.createElement(Popover, { className: props.notification.className, content: props.notification.items?.map((eachItem) => {
499
+ return /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("p", null, eachItem.text), /* @__PURE__ */ React14.createElement("p", null, eachItem.time));
500
+ }), trigger: "focus", placement: "bottomRight" }, /* @__PURE__ */ React14.createElement(Button4, { className: props.notification.buttonClassName }, /* @__PURE__ */ React14.createElement("span", null, props.notification.icon), /* @__PURE__ */ React14.createElement("span", { className: props.notification.countClassName }, props.notification.count)));
501
+
502
+ // src/Components/Profile.tsx
503
+ import React15 from "react";
504
+ var Profile = (props) => /* @__PURE__ */ React15.createElement("div", { className: props.profile.className }, /* @__PURE__ */ React15.createElement("img", { src: props.profile.profileImage, alt: "profile", className: props.profile.profileImageClassName }), /* @__PURE__ */ React15.createElement("div", { className: "flex flex-column space-x-4" }, /* @__PURE__ */ React15.createElement("span", null, props.profile.primaryText), /* @__PURE__ */ React15.createElement("span", { className: props.profile.className }, props.profile.secondaryText)));
505
+
506
+ // src/Components/Navbar.tsx
507
+ var Navbar = (props) => {
508
+ return /* @__PURE__ */ React16.createElement("div", { className: "flex space-between" }, /* @__PURE__ */ React16.createElement("span", { className: props.dashboard.className }, props.dashboard.label), /* @__PURE__ */ React16.createElement("div", { className: "flex flex-end items-center space-x-4" }, /* @__PURE__ */ React16.createElement(Notification, { ...props }), /* @__PURE__ */ React16.createElement(Profile, { ...props })));
363
509
  };
364
510
  export {
365
511
  AddMoreTable,
@@ -367,10 +513,12 @@ export {
367
513
  CheckboxElement,
368
514
  CkEditor,
369
515
  MultipleSelectElement,
516
+ Navbar,
370
517
  NumberElement,
371
518
  PasswordElement,
372
519
  RadioElement,
373
520
  SelectElement,
521
+ Sidebar,
374
522
  SingleSelectElement,
375
523
  TextElement,
376
524
  TextareaElement
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.11-Beta13",
3
+ "version": "0.0.11-Beta130",
4
4
  "description": "Apex cura React components library",
5
+
5
6
  "keywords": [
6
7
  "apex cura",
7
8
  "input",
@@ -36,18 +37,23 @@
36
37
  "@types/react-global-configuration": "^1.3.3",
37
38
  "@types/testing-library__react": "^10.2.0",
38
39
  "antd": "^5.16.5",
40
+ "autoprefixer": "^10.4.19",
39
41
  "jest": "^29.7.0",
40
42
  "jest-environment-jsdom": "^29.7.0",
43
+ "postcss": "^8.4.38",
41
44
  "react": "^18.3.1",
42
45
  "react-dom": "^18.3.1",
46
+ "tailwindcss": "^3.4.3",
43
47
  "ts-jest": "^29.1.2",
44
- "tsup": "^8.0.2",
48
+ "tsup": "^8.1.0",
45
49
  "typescript": "^5.4.5"
46
50
  },
47
51
  "engines": {
48
52
  "node": ">=18.0.0"
49
53
  },
50
54
  "dependencies": {
51
- "@tinymce/tinymce-react": "^5.0.1"
55
+ "@tinymce/tinymce-react": "^5.0.1",
56
+ "esbuild": "^0.21.4",
57
+ "postcss-import": "^16.1.0"
52
58
  }
53
59
  }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: [
3
+ require('tailwindcss'),
4
+ require('autoprefixer'),
5
+ ],
6
+ };
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ content: [
3
+ "./src/**/*.{js,jsx,ts,tsx}", // Adjust this path according to your project structure
4
+ ],
5
+ theme: {
6
+ extend: {},
7
+ },
8
+ plugins: [],
9
+ };