@megha-ui/react 1.2.170 → 1.2.172

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.
Files changed (43) hide show
  1. package/dist/components/block/index.js +3 -5
  2. package/dist/components/button/index.js +3 -5
  3. package/dist/components/button/types/borderStyle.js +1 -2
  4. package/dist/components/button/types/cursorType.js +1 -2
  5. package/dist/components/card/index.js +7 -9
  6. package/dist/components/checkbox/index.js +7 -9
  7. package/dist/components/date-input/index.js +6 -8
  8. package/dist/components/dropdown/index.js +42 -47
  9. package/dist/components/grid/hooks/useBulkSelect.js +6 -10
  10. package/dist/components/grid/hooks/usePagination.js +6 -10
  11. package/dist/components/grid/hooks/useResizeObserver.js +3 -5
  12. package/dist/components/grid/hooks/useSearch.js +3 -7
  13. package/dist/components/grid/hooks/useSort.js +4 -8
  14. package/dist/components/grid/hooks/useVisibleData.js +6 -10
  15. package/dist/components/grid/index.js +150 -186
  16. package/dist/components/grid/types/grid.d.ts +1 -0
  17. package/dist/components/grid/types/grid.js +1 -2
  18. package/dist/components/grid/utils/SummariseDetails.js +12 -17
  19. package/dist/components/grid/utils/calculatedropdown.js +4 -6
  20. package/dist/components/grid/utils/globalSearchChips.js +11 -16
  21. package/dist/components/grid/utils/gridFilterDropdown.js +22 -27
  22. package/dist/components/grid/utils/gridHeader.js +78 -118
  23. package/dist/components/grid/utils/gridHeaderDropdown.js +4 -6
  24. package/dist/components/grid/utils/gridRow.js +29 -34
  25. package/dist/components/grid/utils/groupedGridDetails.js +17 -22
  26. package/dist/components/grid/utils/groupedRow.js +12 -17
  27. package/dist/components/grid/utils/pagination.js +7 -11
  28. package/dist/components/grid/utils/paginationUtils.js +1 -5
  29. package/dist/components/grid/utils/regexUtils.js +2 -7
  30. package/dist/components/grid/utils/shimmer.js +4 -6
  31. package/dist/components/grid/utils/textFilterDropdown.js +8 -13
  32. package/dist/components/loader/index.js +6 -41
  33. package/dist/components/modal/index.js +11 -13
  34. package/dist/components/tabs/index.js +19 -26
  35. package/dist/components/text/index.js +3 -5
  36. package/dist/components/text/textType.js +1 -2
  37. package/dist/components/text-input/index.js +10 -12
  38. package/dist/components/textarea/index.js +3 -5
  39. package/dist/components/texteditor/index.js +25 -27
  40. package/dist/components/toggle/index.js +4 -6
  41. package/dist/index.js +16 -41
  42. package/dist/services/commonService.js +3 -7
  43. package/package.json +1 -1
@@ -1,11 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("react");
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState, useRef } from "react";
5
3
  const Modal = ({ isOpen, onClose, title, subTitle, titleAlign = "left", children, footer, className = "", width, minHeight = 300, padding = "1rem", borderRadius = 6, backgroundColor = "var(--modal-bg)", paddingBottom = "1rem", paddingLeft = "1rem", paddingRight = "1rem", paddingTop = "1rem", contentHeight = "calc(100vh - 180)", overlayClose = false, alignItems, justifyContent, modalContentClass, bodyOverflow = "auto", }) => {
6
- const [removelHeight, setRemovalHeight] = (0, react_1.useState)(0);
7
- const footerRef = (0, react_1.useRef)(null);
8
- (0, react_1.useEffect)(() => {
4
+ const [removelHeight, setRemovalHeight] = useState(0);
5
+ const footerRef = useRef(null);
6
+ useEffect(() => {
9
7
  const handleKeyDown = (event) => {
10
8
  if (event.key === "Escape") {
11
9
  onClose();
@@ -20,7 +18,7 @@ const Modal = ({ isOpen, onClose, title, subTitle, titleAlign = "left", children
20
18
  window.removeEventListener("keydown", handleKeyDown);
21
19
  };
22
20
  }, [isOpen, onClose]);
23
- (0, react_1.useEffect)(() => {
21
+ useEffect(() => {
24
22
  if (title || footer) {
25
23
  }
26
24
  }, [footer, title]);
@@ -45,7 +43,7 @@ const Modal = ({ isOpen, onClose, title, subTitle, titleAlign = "left", children
45
43
  flexDirection: "column",
46
44
  justifyContent: "space-between",
47
45
  };
48
- return ((0, jsx_runtime_1.jsx)("div", { className: `${className}`, style: {
46
+ return (_jsx("div", { className: `${className}`, style: {
49
47
  position: "fixed",
50
48
  top: 0,
51
49
  left: 0,
@@ -56,15 +54,15 @@ const Modal = ({ isOpen, onClose, title, subTitle, titleAlign = "left", children
56
54
  justifyContent,
57
55
  backgroundColor: "rgba(0, 0, 0, 0.5)",
58
56
  zIndex: 1050,
59
- }, onClick: () => overlayClose && onClose(), children: (0, jsx_runtime_1.jsxs)("div", { style: modalContentStyle, className: modalContentClass, onClick: (e) => e.stopPropagation(), children: [title && ((0, jsx_runtime_1.jsxs)("div", { style: {
57
+ }, onClick: () => overlayClose && onClose(), children: _jsxs("div", { style: modalContentStyle, className: modalContentClass, onClick: (e) => e.stopPropagation(), children: [title && (_jsxs("div", { style: {
60
58
  position: "relative",
61
59
  marginBottom: 0,
62
60
  padding: "1rem",
63
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { textAlign: titleAlign }, children: [(0, jsx_runtime_1.jsx)("h4", { style: { fontSize: "1.25rem" }, children: title }), (0, jsx_runtime_1.jsx)("p", { style: { margin: 0 }, children: subTitle })] }), (0, jsx_runtime_1.jsx)("button", { style: { position: "absolute", top: 10, right: 10 }, onClick: onClose, children: "\u00D7" })] })), (0, jsx_runtime_1.jsx)("div", { style: {
61
+ }, children: [_jsxs("div", { style: { textAlign: titleAlign }, children: [_jsx("h4", { style: { fontSize: "1.25rem" }, children: title }), _jsx("p", { style: { margin: 0 }, children: subTitle })] }), _jsx("button", { style: { position: "absolute", top: 10, right: 10 }, onClick: onClose, children: "\u00D7" })] })), _jsx("div", { style: {
64
62
  overflowY: bodyOverflow,
65
63
  height: `calc(${contentHeight} - ${removelHeight}px)`,
66
64
  paddingLeft: "1rem",
67
65
  paddingRight: "1rem",
68
- }, children: children }), footer && ((0, jsx_runtime_1.jsx)("div", { ref: footerRef, style: { marginTop: "auto", padding: "1rem" }, children: footer }))] }) }));
66
+ }, children: children }), footer && (_jsx("div", { ref: footerRef, style: { marginTop: "auto", padding: "1rem" }, children: footer }))] }) }));
69
67
  };
70
- exports.default = Modal;
68
+ export default Modal;
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TabPanel = exports.Tab = exports.TabList = exports.Tabs = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const TabsContext = (0, react_1.createContext)(undefined);
7
- const Tabs = ({ children, defaultActive, className, type = "horizontal", showTabNumber = false, showTabDescription = false, }) => {
8
- const [activeTab, setActiveTab] = (0, react_1.useState)(defaultActive || "");
9
- return ((0, jsx_runtime_1.jsx)(TabsContext.Provider, { value: {
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, createContext, useContext } from "react";
3
+ const TabsContext = createContext(undefined);
4
+ export const Tabs = ({ children, defaultActive, className, type = "horizontal", showTabNumber = false, showTabDescription = false, }) => {
5
+ const [activeTab, setActiveTab] = useState(defaultActive || "");
6
+ return (_jsx(TabsContext.Provider, { value: {
10
7
  activeTab,
11
8
  setActiveTab,
12
9
  type,
13
10
  showTabNumber,
14
11
  showTabDescription,
15
- }, children: (0, jsx_runtime_1.jsx)("div", { className: className, style: {
12
+ }, children: _jsx("div", { className: className, style: {
16
13
  display: "flex",
17
14
  flexDirection: type === "vertical" ? "row" : "column",
18
15
  width: "100%",
@@ -22,14 +19,13 @@ const Tabs = ({ children, defaultActive, className, type = "horizontal", showTab
22
19
  overflow: "hidden",
23
20
  }, children: children }) }));
24
21
  };
25
- exports.Tabs = Tabs;
26
- const TabList = ({ children, width }) => {
27
- const context = (0, react_1.useContext)(TabsContext);
22
+ export const TabList = ({ children, width }) => {
23
+ const context = useContext(TabsContext);
28
24
  if (!context) {
29
25
  throw new Error("TabList component must be used inside Tabs.");
30
26
  }
31
27
  const { type } = context;
32
- return ((0, jsx_runtime_1.jsx)("div", { style: {
28
+ return (_jsx("div", { style: {
33
29
  display: "flex",
34
30
  flexDirection: type === "vertical" ? "column" : "row",
35
31
  width: width ? width : type === "vertical" ? "25%" : "100%",
@@ -37,15 +33,14 @@ const TabList = ({ children, width }) => {
37
33
  flexGrow: 0,
38
34
  }, children: children }));
39
35
  };
40
- exports.TabList = TabList;
41
- const Tab = ({ label, description, tabNumber }) => {
42
- const context = (0, react_1.useContext)(TabsContext);
36
+ export const Tab = ({ label, description, tabNumber }) => {
37
+ const context = useContext(TabsContext);
43
38
  if (!context) {
44
39
  throw new Error("Tab component must be used inside Tabs.");
45
40
  }
46
41
  const { activeTab, setActiveTab, type, showTabNumber, showTabDescription } = context;
47
42
  const isActive = activeTab === label;
48
- return ((0, jsx_runtime_1.jsx)("button", { onClick: () => setActiveTab(label), style: {
43
+ return (_jsx("button", { onClick: () => setActiveTab(label), style: {
49
44
  padding: "0.65rem 0",
50
45
  cursor: "pointer",
51
46
  border: "none",
@@ -55,7 +50,7 @@ const Tab = ({ label, description, tabNumber }) => {
55
50
  borderRadius: "0.25rem",
56
51
  display: "flex",
57
52
  alignItems: "flex-start",
58
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", alignItems: "center" }, children: [showTabNumber && ((0, jsx_runtime_1.jsx)("span", { style: {
53
+ }, children: _jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [showTabNumber && (_jsx("span", { style: {
59
54
  fontWeight: 700,
60
55
  fontSize: "1rem",
61
56
  marginRight: "0.5rem",
@@ -65,26 +60,24 @@ const Tab = ({ label, description, tabNumber }) => {
65
60
  borderRadius: "0.35rem",
66
61
  minWidth: "1.75rem",
67
62
  textAlign: "center",
68
- }, className: "shadow-md", children: tabNumber })), (0, jsx_runtime_1.jsxs)("div", { style: {
63
+ }, className: "shadow-md", children: tabNumber })), _jsxs("div", { style: {
69
64
  display: "flex",
70
65
  flexDirection: "column",
71
- }, children: [(0, jsx_runtime_1.jsx)("span", { style: { fontWeight: 500, fontSize: "1rem" }, children: label }), showTabDescription && description && ((0, jsx_runtime_1.jsx)("span", { style: {
66
+ }, children: [_jsx("span", { style: { fontWeight: 500, fontSize: "1rem" }, children: label }), showTabDescription && description && (_jsx("span", { style: {
72
67
  color: "#4D4D4D",
73
68
  fontWeight: 400,
74
69
  fontSize: "0.85rem",
75
70
  }, children: description }))] })] }) }));
76
71
  };
77
- exports.Tab = Tab;
78
- const TabPanel = ({ label, children, className, }) => {
79
- const context = (0, react_1.useContext)(TabsContext);
72
+ export const TabPanel = ({ label, children, className, }) => {
73
+ const context = useContext(TabsContext);
80
74
  if (!context) {
81
75
  throw new Error("TabPanel component must be used inside Tabs.");
82
76
  }
83
77
  const { activeTab } = context;
84
78
  const isActive = activeTab === label;
85
- return isActive ? ((0, jsx_runtime_1.jsx)("div", { className: className, style: {
79
+ return isActive ? (_jsx("div", { className: className, style: {
86
80
  flex: 1,
87
81
  background: "white",
88
82
  }, children: children })) : null;
89
83
  };
90
- exports.TabPanel = TabPanel;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
1
+ import { jsx as _jsx } from "react/jsx-runtime";
4
2
  const Text = ({ children, as = "span", onClick, className = "", style = {}, color, fontSize, fontWeight, cursor, fontStyle, textAlign, textTransform, lineHeight, letterSpacing, textDecoration, textOverflow, whiteSpace, wordBreak, marginBottom, marginTop, marginLeft, marginRight, fontFamily, borderTopWidth, borderTopColor, borderTopStyle, borderColor, borderWidth, border, borderStyle, borderBottom, borderTop, borderLeft, borderRight, borderBottomColor, borderBottomStyle, borderBottomWidth, borderLeftColor, borderLeftStyle, borderLeftWidth, borderRightColor, borderRightStyle, borderRightWidth, }) => {
5
3
  const Element = as;
6
4
  const StyledText = Object.assign(Object.assign({}, style), { color,
@@ -41,6 +39,6 @@ const Text = ({ children, as = "span", onClick, className = "", style = {}, colo
41
39
  borderRightColor,
42
40
  borderRightStyle,
43
41
  borderRightWidth });
44
- return ((0, jsx_runtime_1.jsx)(Element, { onClick: onClick, className: className, style: StyledText, children: children }));
42
+ return (_jsx(Element, { onClick: onClick, className: className, style: StyledText, children: children }));
45
43
  };
46
- exports.default = Text;
44
+ export default Text;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,14 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("react");
5
- const md_1 = require("react-icons/md");
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { MdClose } from "react-icons/md";
6
4
  const TextInput = ({ value = "", name, id, onChange = () => { }, onKeyDown = () => { }, onBlur = () => { }, placeholder = "", type = "text", className = "", disabled = false, width = "100%", padding = "0.5rem", borderRadius = 4, fontSize = "0.85rem", height = "2.5rem", autoComplete = "off", maxLength, readOnly = false, required, isNumber, marginTop, marginRight, marginBottom, marginLeft, label, border = "1px solid var(--form-border-color, #dbdfe9)", backgroundColor = "transparent", icon, iconPosition = "left", asteriskColor = "red", labelFontSize, labelFontWeight, labelMarginBottom, isValid, validationErrorColor = "red", validationSuccessColor = "green", extraWrapperStyle = {}, extraInputStyle = {}, onSubmit, timeBoundBlur, wrapperClass, isClear = true, clearIcon, clearId }) => {
7
- const [focused, setFocused] = (0, react_1.useState)(false);
8
- const [error, setError] = (0, react_1.useState)(null);
9
- const [timeoutId, setTimeoutId] = (0, react_1.useState)(null);
5
+ const [focused, setFocused] = useState(false);
6
+ const [error, setError] = useState(null);
7
+ const [timeoutId, setTimeoutId] = useState(null);
10
8
  const typingDuration = 3000;
11
- const inputRef = (0, react_1.useRef)(null);
9
+ const inputRef = useRef(null);
12
10
  const handleKeyTimebound = () => {
13
11
  if (timeoutId) {
14
12
  clearTimeout(timeoutId);
@@ -20,7 +18,7 @@ const TextInput = ({ value = "", name, id, onChange = () => { }, onKeyDown = ()
20
18
  }, typingDuration);
21
19
  setTimeoutId(newTimeoutId);
22
20
  };
23
- (0, react_1.useEffect)(() => {
21
+ useEffect(() => {
24
22
  var _a;
25
23
  if (inputRef.current && timeBoundBlur) {
26
24
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('keydown', handleKeyTimebound);
@@ -129,6 +127,6 @@ const TextInput = ({ value = "", name, id, onChange = () => { }, onKeyDown = ()
129
127
  const asteriskStyle = {
130
128
  color: asteriskColor,
131
129
  };
132
- return ((0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", flexDirection: "column" }, children: [label && ((0, jsx_runtime_1.jsxs)("p", { style: labelStyle, children: [label, required && (0, jsx_runtime_1.jsx)("span", { style: asteriskStyle, children: " *" })] })), (0, jsx_runtime_1.jsxs)("div", { style: Object.assign(Object.assign({}, textInputWrapperStyle), extraWrapperStyle), className: `${wrapperClass} custom-border`, children: [icon && iconPosition === "left" && (0, jsx_runtime_1.jsx)("div", { style: iconStyle, children: icon }), (0, jsx_runtime_1.jsx)("input", { ref: inputRef, type: type, value: value, name: name, id: id, placeholder: placeholder, onChange: handleInputChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, style: Object.assign(Object.assign({}, textInputStyle), extraInputStyle), className: className, disabled: disabled, autoComplete: autoComplete, maxLength: maxLength, readOnly: readOnly, required: required }), isClear && value && ((0, jsx_runtime_1.jsx)("div", { style: clearIconStyle, onClick: handleClear, id: clearId, title: "Clear", children: clearIcon ? clearIcon : (0, jsx_runtime_1.jsx)(md_1.MdClose, {}) })), icon && iconPosition === "right" && ((0, jsx_runtime_1.jsx)("div", { style: iconStyle, children: icon }))] })] }));
130
+ return (_jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [label && (_jsxs("p", { style: labelStyle, children: [label, required && _jsx("span", { style: asteriskStyle, children: " *" })] })), _jsxs("div", { style: Object.assign(Object.assign({}, textInputWrapperStyle), extraWrapperStyle), className: `${wrapperClass} custom-border`, children: [icon && iconPosition === "left" && _jsx("div", { style: iconStyle, children: icon }), _jsx("input", { ref: inputRef, type: type, value: value, name: name, id: id, placeholder: placeholder, onChange: handleInputChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, style: Object.assign(Object.assign({}, textInputStyle), extraInputStyle), className: className, disabled: disabled, autoComplete: autoComplete, maxLength: maxLength, readOnly: readOnly, required: required }), isClear && value && (_jsx("div", { style: clearIconStyle, onClick: handleClear, id: clearId, title: "Clear", children: clearIcon ? clearIcon : _jsx(MdClose, {}) })), icon && iconPosition === "right" && (_jsx("div", { style: iconStyle, children: icon }))] })] }));
133
131
  };
134
- exports.default = TextInput;
132
+ export default TextInput;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
2
  const Textarea = ({ value = "", onChange, onBlur = () => { }, placeholder = "", className = "", disabled = false, rows = 4, cols = 50, width = "100%", height, padding = "0.5rem", borderRadius = 4, fontSize = "0.85rem", resize = "none", labelFontSize, labelFontWeight, labelMarginBottom, asteriskColor, label, required, name }) => {
5
3
  const handleTextChange = (event) => {
6
4
  onChange(event);
@@ -23,6 +21,6 @@ const Textarea = ({ value = "", onChange, onBlur = () => { }, placeholder = "",
23
21
  const asteriskStyle = {
24
22
  color: asteriskColor,
25
23
  };
26
- return ((0, jsx_runtime_1.jsxs)("div", { children: [label && ((0, jsx_runtime_1.jsxs)("p", { style: labelStyle, children: [label, required && (0, jsx_runtime_1.jsx)("span", { style: asteriskStyle, children: " *" })] })), (0, jsx_runtime_1.jsx)("textarea", { name: name, value: value, placeholder: placeholder, onChange: handleTextChange, onBlur: onBlur, style: textareaStyle, className: className, disabled: disabled, rows: rows, cols: cols })] }));
24
+ return (_jsxs("div", { children: [label && (_jsxs("p", { style: labelStyle, children: [label, required && _jsx("span", { style: asteriskStyle, children: " *" })] })), _jsx("textarea", { name: name, value: value, placeholder: placeholder, onChange: handleTextChange, onBlur: onBlur, style: textareaStyle, className: className, disabled: disabled, rows: rows, cols: cols })] }));
27
25
  };
28
- exports.default = Textarea;
26
+ export default Textarea;
@@ -1,9 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("react");
5
- const fa_1 = require("react-icons/fa");
6
- const md_1 = require("react-icons/md");
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useRef, useEffect, useState } from "react";
3
+ import { FaBold, FaItalic, FaUnderline, FaStrikethrough, FaImage, FaLink, FaUnlink, FaAlignLeft, FaAlignCenter, FaAlignRight, } from "react-icons/fa";
4
+ import { MdFormatListBulleted, MdFormatListNumbered } from "react-icons/md";
7
5
  const TextEditor = ({ value, onChange, enabledTools = {
8
6
  bold: true,
9
7
  italic: true,
@@ -17,21 +15,21 @@ const TextEditor = ({ value, onChange, enabledTools = {
17
15
  textColor: true,
18
16
  linkOptions: true,
19
17
  }, }) => {
20
- const editorRef = (0, react_1.useRef)(null);
21
- const selectionRef = (0, react_1.useRef)(null);
22
- const [showImageDropdown, setShowImageDropdown] = (0, react_1.useState)(false);
23
- const IconBold = fa_1.FaBold;
24
- const IconItalic = fa_1.FaItalic;
25
- const IconUnderline = fa_1.FaUnderline;
26
- const IconStrikethrough = fa_1.FaStrikethrough;
27
- const IconLink = fa_1.FaLink;
28
- const IconUnlink = fa_1.FaUnlink;
29
- const IconImage = fa_1.FaImage;
30
- const IconAlignLeft = fa_1.FaAlignLeft;
31
- const IconAlignCenter = fa_1.FaAlignCenter;
32
- const IconAlignRight = fa_1.FaAlignRight;
33
- const IconFormatListBulleted = md_1.MdFormatListBulleted;
34
- const IconFormatListNumbered = md_1.MdFormatListNumbered;
18
+ const editorRef = useRef(null);
19
+ const selectionRef = useRef(null);
20
+ const [showImageDropdown, setShowImageDropdown] = useState(false);
21
+ const IconBold = FaBold;
22
+ const IconItalic = FaItalic;
23
+ const IconUnderline = FaUnderline;
24
+ const IconStrikethrough = FaStrikethrough;
25
+ const IconLink = FaLink;
26
+ const IconUnlink = FaUnlink;
27
+ const IconImage = FaImage;
28
+ const IconAlignLeft = FaAlignLeft;
29
+ const IconAlignCenter = FaAlignCenter;
30
+ const IconAlignRight = FaAlignRight;
31
+ const IconFormatListBulleted = MdFormatListBulleted;
32
+ const IconFormatListNumbered = MdFormatListNumbered;
35
33
  const wrapSelection = (tag) => {
36
34
  const selection = document.getSelection();
37
35
  if (!selection || selection.rangeCount === 0)
@@ -190,7 +188,7 @@ const TextEditor = ({ value, onChange, enabledTools = {
190
188
  onChange(htmlContent);
191
189
  setTimeout(restoreSelection, 0);
192
190
  };
193
- (0, react_1.useEffect)(() => {
191
+ useEffect(() => {
194
192
  if (editorRef.current && editorRef.current.innerHTML !== value) {
195
193
  saveSelection();
196
194
  editorRef.current.innerHTML = value;
@@ -204,25 +202,25 @@ const TextEditor = ({ value, onChange, enabledTools = {
204
202
  window.open(target.getAttribute("href"), "_blank");
205
203
  }
206
204
  };
207
- return ((0, jsx_runtime_1.jsxs)("div", { style: {
205
+ return (_jsxs("div", { style: {
208
206
  width: "100%",
209
207
  border: "1px solid #ccc",
210
208
  borderRadius: "0.25rem",
211
209
  padding: "0.65rem",
212
210
  position: "relative",
213
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
211
+ }, children: [_jsxs("div", { style: {
214
212
  display: "flex",
215
213
  gap: "0.65rem",
216
214
  marginBottom: "0.65rem",
217
215
  borderBottom: "1px solid #ccc",
218
216
  paddingBottom: "0.25rem",
219
217
  flexWrap: "wrap",
220
- }, children: [enabledTools.headingOptions && ((0, jsx_runtime_1.jsxs)("select", { onChange: (e) => applyHeading(e.target.value), style: buttonStyle, children: [(0, jsx_runtime_1.jsx)("option", { value: "p", children: "Normal" }), (0, jsx_runtime_1.jsx)("option", { value: "h1", children: "H1" }), (0, jsx_runtime_1.jsx)("option", { value: "h2", children: "H2" }), (0, jsx_runtime_1.jsx)("option", { value: "h3", children: "H3" })] })), enabledTools.bold && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => toggleFormat("bold"), style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconBold, {}) })), enabledTools.italic && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => toggleFormat("italic"), style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconItalic, {}) })), enabledTools.underline && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => toggleFormat("underline"), style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconUnderline, {}) })), enabledTools.strikeThrough && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => toggleFormat("strikeThrough"), style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconStrikethrough, {}) })), enabledTools.bulletList && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => insertList("ul"), style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconFormatListBulleted, {}) })), enabledTools.numberList && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => insertList("ol"), style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconFormatListNumbered, {}) })), enabledTools.textAlign && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => toggleFormat("justifyLeft"), style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconAlignLeft, {}) }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => toggleFormat("justifyCenter"), style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconAlignCenter, {}) }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => toggleFormat("justifyRight"), style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconAlignRight, {}) })] })), enabledTools.textColor && ((0, jsx_runtime_1.jsx)("input", { type: "color", onChange: (e) => toggleFormat("foreColor", e.target.value), style: Object.assign(Object.assign({}, buttonStyle), { width: 32, padding: 0 }) })), enabledTools.imageUpload && ((0, jsx_runtime_1.jsxs)("div", { style: { position: "relative" }, children: [(0, jsx_runtime_1.jsx)("button", { type: "button", onClick: toggleImageDropdown, style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconImage, {}) }), showImageDropdown && ((0, jsx_runtime_1.jsxs)("div", { style: dropdownStyle, children: [(0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => {
218
+ }, children: [enabledTools.headingOptions && (_jsxs("select", { onChange: (e) => applyHeading(e.target.value), style: buttonStyle, children: [_jsx("option", { value: "p", children: "Normal" }), _jsx("option", { value: "h1", children: "H1" }), _jsx("option", { value: "h2", children: "H2" }), _jsx("option", { value: "h3", children: "H3" })] })), enabledTools.bold && (_jsx("button", { type: "button", onClick: () => toggleFormat("bold"), style: buttonStyle, children: _jsx(IconBold, {}) })), enabledTools.italic && (_jsx("button", { type: "button", onClick: () => toggleFormat("italic"), style: buttonStyle, children: _jsx(IconItalic, {}) })), enabledTools.underline && (_jsx("button", { type: "button", onClick: () => toggleFormat("underline"), style: buttonStyle, children: _jsx(IconUnderline, {}) })), enabledTools.strikeThrough && (_jsx("button", { type: "button", onClick: () => toggleFormat("strikeThrough"), style: buttonStyle, children: _jsx(IconStrikethrough, {}) })), enabledTools.bulletList && (_jsx("button", { type: "button", onClick: () => insertList("ul"), style: buttonStyle, children: _jsx(IconFormatListBulleted, {}) })), enabledTools.numberList && (_jsx("button", { type: "button", onClick: () => insertList("ol"), style: buttonStyle, children: _jsx(IconFormatListNumbered, {}) })), enabledTools.textAlign && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: () => toggleFormat("justifyLeft"), style: buttonStyle, children: _jsx(IconAlignLeft, {}) }), _jsx("button", { type: "button", onClick: () => toggleFormat("justifyCenter"), style: buttonStyle, children: _jsx(IconAlignCenter, {}) }), _jsx("button", { type: "button", onClick: () => toggleFormat("justifyRight"), style: buttonStyle, children: _jsx(IconAlignRight, {}) })] })), enabledTools.textColor && (_jsx("input", { type: "color", onChange: (e) => toggleFormat("foreColor", e.target.value), style: Object.assign(Object.assign({}, buttonStyle), { width: 32, padding: 0 }) })), enabledTools.imageUpload && (_jsxs("div", { style: { position: "relative" }, children: [_jsx("button", { type: "button", onClick: toggleImageDropdown, style: buttonStyle, children: _jsx(IconImage, {}) }), showImageDropdown && (_jsxs("div", { style: dropdownStyle, children: [_jsx("button", { type: "button", onClick: () => {
221
219
  const url = prompt("Enter Image URL:");
222
220
  if (url)
223
221
  insertImage(url);
224
222
  setShowImageDropdown(false);
225
- }, style: dropdownItemStyle, children: "Insert from URL" }), (0, jsx_runtime_1.jsxs)("label", { style: Object.assign(Object.assign({}, dropdownItemStyle), { cursor: "pointer" }), children: ["Upload from Computer", (0, jsx_runtime_1.jsx)("input", { type: "file", accept: "image/*", onChange: handleImageUpload, style: { display: "none" } })] })] }))] })), enabledTools.linkOptions && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { type: "button", onClick: insertLink, style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconLink, {}) }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: removeLink, style: buttonStyle, children: (0, jsx_runtime_1.jsx)(IconUnlink, {}) })] }))] }), (0, jsx_runtime_1.jsx)("div", { ref: editorRef, contentEditable: true, onInput: updateContent, onClick: handleEditorClick, suppressContentEditableWarning: true, style: {
223
+ }, style: dropdownItemStyle, children: "Insert from URL" }), _jsxs("label", { style: Object.assign(Object.assign({}, dropdownItemStyle), { cursor: "pointer" }), children: ["Upload from Computer", _jsx("input", { type: "file", accept: "image/*", onChange: handleImageUpload, style: { display: "none" } })] })] }))] })), enabledTools.linkOptions && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: insertLink, style: buttonStyle, children: _jsx(IconLink, {}) }), _jsx("button", { type: "button", onClick: removeLink, style: buttonStyle, children: _jsx(IconUnlink, {}) })] }))] }), _jsx("div", { ref: editorRef, contentEditable: true, onInput: updateContent, onClick: handleEditorClick, suppressContentEditableWarning: true, style: {
226
224
  minHeight: "10rem",
227
225
  padding: "0.65rem",
228
226
  border: "1px solid #ddd",
@@ -259,4 +257,4 @@ const dropdownItemStyle = {
259
257
  textAlign: "left",
260
258
  width: "100%",
261
259
  };
262
- exports.default = TextEditor;
260
+ export default TextEditor;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
2
  const Toggle = ({ isChecked = false, onChange, label, disabled = false, activeColor = "#2377ba", className = "", style = {}, labelPosition = "left" }) => {
5
3
  const handleToggleChange = (event) => {
6
4
  onChange(event.target.checked);
@@ -40,10 +38,10 @@ const Toggle = ({ isChecked = false, onChange, label, disabled = false, activeCo
40
38
  left: 0,
41
39
  transform: "translateX(1.375rem)",
42
40
  };
43
- return ((0, jsx_runtime_1.jsxs)("div", { className: `toggle-switch-container ${className}`, style: Object.assign(Object.assign({}, style), { display: 'flex', alignItems: 'center' }), children: [label && labelPosition === "left" && (0, jsx_runtime_1.jsx)("span", { className: "toggle-switch-label", style: { marginRight: 12 }, children: label }), (0, jsx_runtime_1.jsxs)("label", { className: "toggle-switch", style: defaultStyles, children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: isChecked, onChange: handleToggleChange, disabled: disabled, className: "toggle-switch-checkbox", style: {
41
+ return (_jsxs("div", { className: `toggle-switch-container ${className}`, style: Object.assign(Object.assign({}, style), { display: 'flex', alignItems: 'center' }), children: [label && labelPosition === "left" && _jsx("span", { className: "toggle-switch-label", style: { marginRight: 12 }, children: label }), _jsxs("label", { className: "toggle-switch", style: defaultStyles, children: [_jsx("input", { type: "checkbox", checked: isChecked, onChange: handleToggleChange, disabled: disabled, className: "toggle-switch-checkbox", style: {
44
42
  opacity: 0,
45
43
  width: 0,
46
44
  height: 0,
47
- } }), (0, jsx_runtime_1.jsx)("span", { className: "toggle-switch-slider", style: Object.assign(Object.assign({}, sliderStyles), (isChecked ? sliderCheckedStyles : {})), children: (0, jsx_runtime_1.jsx)("span", { style: Object.assign(Object.assign({}, sliderBeforeStyles), (isChecked ? sliderBeforeCheckedStyles : {})) }) })] }), label && labelPosition === "right" && (0, jsx_runtime_1.jsx)("span", { className: "toggle-switch-label", style: { marginRight: 12 }, children: label })] }));
45
+ } }), _jsx("span", { className: "toggle-switch-slider", style: Object.assign(Object.assign({}, sliderStyles), (isChecked ? sliderCheckedStyles : {})), children: _jsx("span", { style: Object.assign(Object.assign({}, sliderBeforeStyles), (isChecked ? sliderBeforeCheckedStyles : {})) }) })] }), label && labelPosition === "right" && _jsx("span", { className: "toggle-switch-label", style: { marginRight: 12 }, children: label })] }));
48
46
  };
49
- exports.default = Toggle;
47
+ export default Toggle;
package/dist/index.js CHANGED
@@ -1,41 +1,16 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.formatValue = exports.TabPanel = exports.TabList = exports.Tab = exports.Tabs = exports.Toggle = exports.TextEditor = exports.Textarea = exports.TextInput = exports.Text = exports.Modal = exports.Loader = exports.Grid = exports.Dropdown = exports.DateInput = exports.Checkbox = exports.Card = exports.Button = exports.Block = void 0;
7
- var block_1 = require("./components/block");
8
- Object.defineProperty(exports, "Block", { enumerable: true, get: function () { return __importDefault(block_1).default; } });
9
- var button_1 = require("./components/button");
10
- Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return __importDefault(button_1).default; } });
11
- var card_1 = require("./components/card");
12
- Object.defineProperty(exports, "Card", { enumerable: true, get: function () { return __importDefault(card_1).default; } });
13
- var checkbox_1 = require("./components/checkbox");
14
- Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return __importDefault(checkbox_1).default; } });
15
- var date_input_1 = require("./components/date-input");
16
- Object.defineProperty(exports, "DateInput", { enumerable: true, get: function () { return __importDefault(date_input_1).default; } });
17
- var dropdown_1 = require("./components/dropdown");
18
- Object.defineProperty(exports, "Dropdown", { enumerable: true, get: function () { return __importDefault(dropdown_1).default; } });
19
- var grid_1 = require("./components/grid");
20
- Object.defineProperty(exports, "Grid", { enumerable: true, get: function () { return __importDefault(grid_1).default; } });
21
- var loader_1 = require("./components/loader");
22
- Object.defineProperty(exports, "Loader", { enumerable: true, get: function () { return __importDefault(loader_1).default; } });
23
- var modal_1 = require("./components/modal");
24
- Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return __importDefault(modal_1).default; } });
25
- var text_1 = require("./components/text");
26
- Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return __importDefault(text_1).default; } });
27
- var text_input_1 = require("./components/text-input");
28
- Object.defineProperty(exports, "TextInput", { enumerable: true, get: function () { return __importDefault(text_input_1).default; } });
29
- var textarea_1 = require("./components/textarea");
30
- Object.defineProperty(exports, "Textarea", { enumerable: true, get: function () { return __importDefault(textarea_1).default; } });
31
- var texteditor_1 = require("./components/texteditor");
32
- Object.defineProperty(exports, "TextEditor", { enumerable: true, get: function () { return __importDefault(texteditor_1).default; } });
33
- var toggle_1 = require("./components/toggle");
34
- Object.defineProperty(exports, "Toggle", { enumerable: true, get: function () { return __importDefault(toggle_1).default; } });
35
- var tabs_1 = require("./components/tabs");
36
- Object.defineProperty(exports, "Tabs", { enumerable: true, get: function () { return tabs_1.Tabs; } });
37
- Object.defineProperty(exports, "Tab", { enumerable: true, get: function () { return tabs_1.Tab; } });
38
- Object.defineProperty(exports, "TabList", { enumerable: true, get: function () { return tabs_1.TabList; } });
39
- Object.defineProperty(exports, "TabPanel", { enumerable: true, get: function () { return tabs_1.TabPanel; } });
40
- var commonService_1 = require("./services/commonService");
41
- Object.defineProperty(exports, "formatValue", { enumerable: true, get: function () { return commonService_1.formatValue; } });
1
+ export { default as Block } from "./components/block";
2
+ export { default as Button } from "./components/button";
3
+ export { default as Card } from "./components/card";
4
+ export { default as Checkbox } from "./components/checkbox";
5
+ export { default as DateInput } from "./components/date-input";
6
+ export { default as Dropdown } from "./components/dropdown";
7
+ export { default as Grid } from "./components/grid";
8
+ export { default as Loader } from "./components/loader";
9
+ export { default as Modal } from "./components/modal";
10
+ export { default as Text } from "./components/text";
11
+ export { default as TextInput } from "./components/text-input";
12
+ export { default as Textarea } from "./components/textarea";
13
+ export { default as TextEditor } from "./components/texteditor";
14
+ export { default as Toggle } from "./components/toggle";
15
+ export { Tabs, Tab, TabList, TabPanel } from "./components/tabs";
16
+ export { formatValue } from "./services/commonService";
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatValue = void 0;
4
- const regexUtils_1 = require("../components/grid/utils/regexUtils");
1
+ import { isValidDateFormat } from "../components/grid/utils/regexUtils";
5
2
  // Function to format numbers
6
3
  const formatNumber = (value, locale = "sv-SE", options) => {
7
4
  const formatter = new Intl.NumberFormat(locale, options);
@@ -159,7 +156,7 @@ const formatCurrency = (value, locale = "sv-SE", currency = "SEK", options) => {
159
156
  }
160
157
  };
161
158
  // Dynamic formatter function
162
- const formatValue = (value, type = "number", locale = "sv-SE", options) => {
159
+ export const formatValue = (value, type = "number", locale = "sv-SE", options) => {
163
160
  if (type === "number") {
164
161
  const num = parseFloat(value.toString());
165
162
  return formatNumber(num, locale, { useGrouping: false });
@@ -174,7 +171,7 @@ const formatValue = (value, type = "number", locale = "sv-SE", options) => {
174
171
  date = d ? toISODateTime(d) : "";
175
172
  }
176
173
  if (typeof value === "string") {
177
- if (!(0, regexUtils_1.isValidDateFormat)(value))
174
+ if (!isValidDateFormat(value))
178
175
  return value;
179
176
  const d = parseSupportedDate(value);
180
177
  date = d ? toISODateTime(d) : "";
@@ -210,4 +207,3 @@ const formatValue = (value, type = "number", locale = "sv-SE", options) => {
210
207
  return value.toString();
211
208
  }
212
209
  };
213
- exports.formatValue = formatValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.170",
3
+ "version": "1.2.172",
4
4
  "description": "A collection of reusable UI components for React applications, built with TypeScript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",