@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.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,58 @@ 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 radioDefaultStyle = "bg-[#F2F2F2] border border-[#919191] rounded-[8px] m-[10px] hover:bg-[#F2F2F2] text-center text-black shadow-[0px_0px_1px_1px_#919191]";
143
+ 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]";
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 selectedLabel = e.target.label;
151
+ const selectedOptions = [{ id: selectedLabel, value: selectedVal }];
152
+ setSelectedValue(selectedVal);
153
+ setIsDisabled(true);
145
154
  if (props.onChange) {
146
- const selectedVal = e.target.value;
147
- const selectedOptions = [{ id: selectedVal, value: selectedVal }];
148
155
  props.onChange(selectedOptions);
149
156
  }
150
157
  };
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"));
158
+ const getButtonStyle = (option) => {
159
+ return selectedValue === option.value ? `${radioSelectedDefaultStyle} ${option.selectedClassName}` : `${radioDefaultStyle} ${option.className}`;
160
+ };
161
+ return /* @__PURE__ */ React6.createElement("div", { className: containerClassName }, /* @__PURE__ */ React6.createElement("p", null, props.label), /* @__PURE__ */ React6.createElement(
162
+ Radio.Group,
163
+ {
164
+ onChange: handleChange,
165
+ optionType,
166
+ className: props.className,
167
+ value: selectedValue
168
+ },
169
+ props.options && props.options.map((option) => /* @__PURE__ */ React6.createElement(
170
+ Radio,
171
+ {
172
+ key: option.value,
173
+ value: option.value,
174
+ disabled: isDisabled && selectedValue !== option.value,
175
+ className: getButtonStyle(option),
176
+ style: { pointerEvents: isDisabled && selectedValue !== option.value ? "none" : "auto" }
177
+ },
178
+ option.label
179
+ ))
180
+ ));
152
181
  };
153
182
 
154
183
  // src/Components/Checkbox.tsx
155
- import React7, { useState as useState2 } from "react";
184
+ import React7, { useState as useState3 } from "react";
156
185
  import { Checkbox, Divider } from "antd";
157
186
  var CheckboxGroup = Checkbox.Group;
158
187
  var plainOptions = ["Apple", "Pear", "Orange"];
159
188
  var defaultCheckedList = [];
160
189
  var CheckboxElement = (props) => {
161
- const [checkedList, setCheckedList] = useState2(defaultCheckedList);
190
+ const [checkedList, setCheckedList] = useState3(defaultCheckedList);
162
191
  const checkAll = plainOptions.length === checkedList.length;
163
192
  const handleChange = (list) => {
164
193
  setCheckedList(list);
@@ -182,7 +211,7 @@ var CheckboxElement = (props) => {
182
211
  disabled: props.disabled,
183
212
  id: props.name,
184
213
  style: props.styles,
185
- className: props.classNames,
214
+ className: props.className,
186
215
  onChange: onHandleAllChanges,
187
216
  checked: checkAll
188
217
  },
@@ -192,7 +221,7 @@ var CheckboxElement = (props) => {
192
221
  {
193
222
  disabled: props.disabled,
194
223
  style: props.styles,
195
- className: props.classNames,
224
+ className: props.className,
196
225
  options: plainOptions,
197
226
  value: checkedList,
198
227
  onChange: handleChange
@@ -219,8 +248,7 @@ var CkEditor = (props) => {
219
248
  {
220
249
  apiKey: "rwpgt7maa54n0pe5mglhkl686p7h57sg6z636n6gf2mio1b9",
221
250
  onInit: (_evt, editor) => {
222
- if (editor)
223
- editorRef.current = editor;
251
+ if (editor) editorRef.current = editor;
224
252
  },
225
253
  initialValue: "<p>This is the initial content of the editor.</p>",
226
254
  init: {
@@ -308,90 +336,186 @@ var MultipleSelectElement = (props) => {
308
336
 
309
337
  // src/Components/Button.tsx
310
338
  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"));
339
+ import { Button as Button2 } from "antd";
340
+ var defaultClassName = "w-[126px] h-[40px] bg-purple-800 text-white rounded-full shadow-lg submit border-none";
341
+ var ButtonElement = (props) => {
342
+ const handleClick = typeof props.action === "string" ? () => {
343
+ console.log("Performing action:", props.action);
344
+ } : props.action;
345
+ return /* @__PURE__ */ React11.createElement(
346
+ Button2,
347
+ {
348
+ onClick: handleClick,
349
+ className: `${defaultClassName} ${props.className ? props.className : ""}`
350
+ },
351
+ props.label
352
+ );
353
+ };
313
354
 
314
355
  // src/Components/AddMoreTable.tsx
315
- import React12, { useState as useState3 } from "react";
316
- import { Table } from "antd";
356
+ import React12, { useEffect, useState as useState4 } from "react";
357
+ import { Table, Button as Button3 } from "antd";
317
358
  import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
318
359
  var AddMoreTable = (props) => {
319
360
  const { thead, tbody } = props;
320
- const [tableData, setTableData] = useState3({});
321
- const [rows, setRows] = useState3(tbody || []);
322
- function isColumnType(column) {
323
- return column.dataIndex !== void 0;
324
- }
325
- const onHandleChange = (name, value) => {
326
- setTableData((prev) => ({ ...prev, [name]: value }));
327
- console.log(tableData);
328
- };
361
+ const [rows, setRows] = useState4(tbody || []);
329
362
  const onHandleRows = () => {
330
- const lastRow = rows[rows.length - 1];
331
- const newId = lastRow ? lastRow.id + 1 : lastRow.id;
332
- const newRow = {
333
- ...lastRow,
334
- id: newId
363
+ const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
364
+ let newRow = {
365
+ id: newId,
366
+ label: "Medicine",
367
+ name: "Medicine",
368
+ type: "text",
369
+ element: "single-select",
370
+ variable_data: [
371
+ {
372
+ id: 1,
373
+ Route: { label: "Route", element: "single-select", type: "text" },
374
+ Dose: { label: "Dose", element: "single-select", type: "text" },
375
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
376
+ When: { label: "When", element: "textarea", type: "text" },
377
+ Duration: { label: "Duration", element: "textarea", type: "text" },
378
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
379
+ SubRows: { delete: "delete", add: "plus" }
380
+ }
381
+ ]
335
382
  };
336
383
  setRows((prevData) => [...prevData, newRow]);
337
384
  };
338
- const onHandleDelete = (index) => {
339
- const remainingRows = rows.filter((eachRow) => eachRow.id !== index);
340
- setRows(remainingRows);
385
+ const onHandleDelete = (id) => {
386
+ setRows((prevRows) => prevRows.filter((row) => row.id !== id));
341
387
  };
342
- const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
343
- title: eachHeadEl.label,
344
- dataIndex: eachHeadEl.name,
345
- key: eachHeadEl.id
346
- })) : [];
347
- const renderInputElement = (element) => {
388
+ const onHandleSubRowsAdd = (rowIndex) => {
389
+ setRows((prevRows) => {
390
+ return prevRows.map((row, index) => {
391
+ if (index === rowIndex) {
392
+ const newSubRow = {
393
+ id: row.variable_data.length + 1,
394
+ Route: { label: "Route", element: "single-select", type: "text" },
395
+ Dose: { label: "Dose", element: "single-select", type: "text" },
396
+ Frequency: { label: "Frequency", element: "single-select", type: "text" },
397
+ When: { label: "When", element: "textarea", type: "text" },
398
+ Duration: { label: "Duration", element: "textarea", type: "text" },
399
+ Instructions: { label: "Instructions", element: "textarea", type: "text" },
400
+ SubRows: { delete: "delete", add: "plus" }
401
+ };
402
+ const updatedVariableData = [...row.variable_data, newSubRow];
403
+ return {
404
+ ...row,
405
+ variable_data: updatedVariableData
406
+ };
407
+ }
408
+ return row;
409
+ });
410
+ });
411
+ };
412
+ const onHandleSubRowsDelete = (rowIndex, subIndex) => {
413
+ setRows((prevRows) => {
414
+ return prevRows.map((row, index) => {
415
+ if (index === rowIndex) {
416
+ const updatedVariableData = row.variable_data.filter((_, i) => i !== subIndex);
417
+ return {
418
+ ...row,
419
+ variable_data: updatedVariableData
420
+ };
421
+ }
422
+ return row;
423
+ });
424
+ });
425
+ };
426
+ useEffect(() => {
427
+ console.log(rows);
428
+ }, [rows]);
429
+ const renderInputElement = (element, value) => {
430
+ if (!element) return null;
348
431
  const { element: type, label } = element;
349
- console.log("type....", type);
350
432
  if (type === "single-select") {
351
- return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value) => onHandleChange(label, value) });
433
+ return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
352
434
  } else if (type === "textarea") {
353
- return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value) => onHandleChange(label, value) });
435
+ return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
354
436
  } else {
355
437
  return null;
356
438
  }
357
439
  };
358
- const dataSource = rows.map((eachRow, index) => {
359
- const rowElements = {};
360
- if (eachRow.element && eachRow.label) {
361
- rowElements[eachRow.label] = renderInputElement(eachRow);
362
- }
363
- const variableData = eachRow.variable_data && Array.isArray(eachRow.variable_data) ? eachRow.variable_data.reduce((acc, curr) => {
364
- if (!curr.label || !curr.element) {
365
- console.error(`Invalid element in row ${index}:`, curr);
366
- return acc;
367
- }
368
- acc[curr.label] = renderInputElement(curr);
369
- return acc;
370
- }, {}) : {};
371
- return {
372
- key: index.toString(),
373
- "#": index + 1,
374
- ...eachRow,
375
- ...rowElements,
376
- ...variableData,
377
- actions: /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("button", { onClick: () => onHandleDelete(eachRow.id) }, /* @__PURE__ */ React12.createElement(DeleteOutlined, null)), index === rows.length - 1 && /* @__PURE__ */ React12.createElement("button", { onClick: onHandleRows }, /* @__PURE__ */ React12.createElement(PlusOutlined, null)))
440
+ const dataSource = rows.map((eachRow, rowIndex) => {
441
+ const rowData = {
442
+ key: eachRow.id,
443
+ "#": rowIndex + 1,
444
+ "Medicine": renderInputElement({
445
+ element: eachRow.element,
446
+ label: eachRow.label
447
+ })
378
448
  };
449
+ eachRow.variable_data.forEach((variable, subIndex) => {
450
+ Object.keys(variable).forEach((key) => {
451
+ if (key === "SubRows") {
452
+ 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)));
453
+ } else {
454
+ rowData[`${key}`] = renderInputElement(variable[key]);
455
+ }
456
+ });
457
+ });
458
+ 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)));
459
+ console.log("=====rowdata", rowData);
460
+ return rowData;
379
461
  });
380
- if (!columns.some((col) => isColumnType(col) && col.dataIndex === "actions")) {
462
+ const columns = thead && thead.length > 0 ? thead.map((eachHeadEl) => ({
463
+ title: eachHeadEl.label,
464
+ dataIndex: eachHeadEl.name,
465
+ key: eachHeadEl.id
466
+ })) : [];
467
+ if (!columns.some((col) => col.dataIndex === "actions")) {
381
468
  columns.push({
382
469
  title: "Actions",
383
470
  dataIndex: "actions",
384
471
  key: "actions"
385
472
  });
386
473
  }
387
- return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
474
+ return /* @__PURE__ */ React12.createElement(
388
475
  Table,
389
476
  {
390
477
  columns,
391
- expandable: { defaultExpandedRowKeys: ["0"] },
392
- dataSource
478
+ dataSource,
479
+ pagination: false,
480
+ bordered: true
393
481
  }
394
- ));
482
+ );
483
+ };
484
+
485
+ // src/Components/Sidebar.tsx
486
+ import React13 from "react";
487
+ var Sidebar = (props) => {
488
+ const handleChange = (item) => {
489
+ if (props.onChange) {
490
+ props.onChange(item);
491
+ }
492
+ };
493
+ return /* @__PURE__ */ React13.createElement("div", { className: props.className, key: props.name }, /* @__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) => {
494
+ return /* @__PURE__ */ React13.createElement("li", { onClick: () => {
495
+ handleChange(item);
496
+ }, key: item.label, className: `${props.listItemClassName} ${item.active && props.activeClassName}` }, /* @__PURE__ */ React13.createElement("span", null, item.icon), /* @__PURE__ */ React13.createElement("span", null, item.label));
497
+ })));
498
+ };
499
+
500
+ // src/Components/Navbar.tsx
501
+ import React16 from "react";
502
+
503
+ // src/Components/Notofication.tsx
504
+ import React14 from "react";
505
+ import { Popover, Badge } from "antd";
506
+ var Notification = (props) => /* @__PURE__ */ React14.createElement(Popover, { className: props.notification.className, content: props.notification.items?.map((eachItem) => {
507
+ return /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("p", null, eachItem.text), /* @__PURE__ */ React14.createElement("p", null, eachItem.time));
508
+ }), trigger: "focus", placement: "bottomRight" }, /* @__PURE__ */ React14.createElement(Badge, { count: props.notification.count }, props.notification.icon));
509
+
510
+ // src/Components/Profile.tsx
511
+ import React15 from "react";
512
+ 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: props.profile.profileSubClassName }, /* @__PURE__ */ React15.createElement("span", null, props.profile.primaryText), /* @__PURE__ */ React15.createElement("span", null, props.profile.secondaryText)));
513
+
514
+ // src/Components/Navbar.tsx
515
+ var Navbar = (props) => {
516
+ const test = "w-full flex justify-between";
517
+ const dashboradClass = "text-xl,text-default-600";
518
+ return /* @__PURE__ */ React16.createElement("div", { className: `${test} ${props.subContainerClassName}` }, /* @__PURE__ */ React16.createElement("div", { className: `${dashboradClass} ${props.dashboard.className}` }, props.dashboard.label), /* @__PURE__ */ React16.createElement("div", { className: "flex" }, /* @__PURE__ */ React16.createElement(Notification, { ...props }), /* @__PURE__ */ React16.createElement(Profile, { ...props })));
395
519
  };
396
520
  export {
397
521
  AddMoreTable,
@@ -399,10 +523,12 @@ export {
399
523
  CheckboxElement,
400
524
  CkEditor,
401
525
  MultipleSelectElement,
526
+ Navbar,
402
527
  NumberElement,
403
528
  PasswordElement,
404
529
  RadioElement,
405
530
  SelectElement,
531
+ Sidebar,
406
532
  SingleSelectElement,
407
533
  TextElement,
408
534
  TextareaElement
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.12-Beta7",
3
+ "version": "0.0.12-Beta71",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",
@@ -41,13 +41,18 @@
41
41
  "react": "^18.3.1",
42
42
  "react-dom": "^18.3.1",
43
43
  "ts-jest": "^29.1.2",
44
- "tsup": "^8.0.2",
44
+ "tsup": "^8.1.0",
45
45
  "typescript": "^5.4.5"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=18.0.0"
49
49
  },
50
50
  "dependencies": {
51
- "@tinymce/tinymce-react": "^5.0.1"
51
+ "@tinymce/tinymce-react": "^5.0.1",
52
+ "autoprefixer": "^10.4.19",
53
+ "esbuild": "^0.21.4",
54
+ "postcss": "^8.4.38",
55
+ "postcss-import": "^16.1.0",
56
+ "tailwindcss": "^3.4.3"
52
57
  }
53
58
  }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
@@ -0,0 +1,10 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+
4
+ content: ['./src/**/*.{js,jsx,ts,tsx}'],
5
+ theme: {
6
+ extend: {},
7
+ },
8
+ plugins: [],
9
+ }
10
+