@megha-ui/react 1.2.676 → 1.2.677

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.
@@ -44,6 +44,8 @@ interface TextInputProps {
44
44
  isClear?: boolean;
45
45
  clearIcon?: React.ReactNode;
46
46
  clearId?: string;
47
+ compactDisplay?: boolean;
48
+ ultraCompactDisplay?: boolean;
47
49
  }
48
50
  declare const TextInput: React.FC<TextInputProps>;
49
51
  export default TextInput;
@@ -1,7 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from "react";
3
3
  import { MdClose } from "react-icons/md";
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 }) => {
4
+ import { useDensity } from "../../context/DensityContext";
5
+ 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, compactDisplay = false, ultraCompactDisplay = false, clearIcon, clearId, }) => {
6
+ const { density } = useDensity();
5
7
  const [focused, setFocused] = useState(false);
6
8
  const [error, setError] = useState(null);
7
9
  const [timeoutId, setTimeoutId] = useState(null);
@@ -14,17 +16,17 @@ const TextInput = ({ value = "", name, id, onChange = () => { }, onKeyDown = ()
14
16
  const newTimeoutId = setTimeout(() => {
15
17
  var _a;
16
18
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
17
- console.log('Timebound unfocusing...');
19
+ console.log("Timebound unfocusing...");
18
20
  }, typingDuration);
19
21
  setTimeoutId(newTimeoutId);
20
22
  };
21
23
  useEffect(() => {
22
24
  var _a;
23
25
  if (inputRef.current && timeBoundBlur) {
24
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('keydown', handleKeyTimebound);
26
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener("keydown", handleKeyTimebound);
25
27
  return () => {
26
28
  var _a;
27
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', handleKeyTimebound);
29
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", handleKeyTimebound);
28
30
  if (timeoutId) {
29
31
  clearTimeout(timeoutId); // Clean up the timeout when component is unmounted
30
32
  }
@@ -75,9 +77,15 @@ const TextInput = ({ value = "", name, id, onChange = () => { }, onKeyDown = ()
75
77
  onChange(event);
76
78
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
77
79
  };
78
- const textInputWrapperStyle = Object.assign(Object.assign({ display: "flex", alignItems: "center", width,
79
- height,
80
- backgroundColor, border: error && !focused
80
+ const textInputWrapperStyle = Object.assign(Object.assign({ display: "flex", alignItems: "center", width, minHeight: `var(--control-min-height, ${ultraCompactDisplay
81
+ ? "1.5rem"
82
+ : compactDisplay
83
+ ? "2rem"
84
+ : density === "ultraCompact"
85
+ ? "1.5rem"
86
+ : density === "compact"
87
+ ? "2rem"
88
+ : "2.5rem"})`, backgroundColor, border: error && !focused
81
89
  ? `1px solid ${validationErrorColor}`
82
90
  : isValid
83
91
  ? `1px solid ${validationSuccessColor}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.676",
3
+ "version": "1.2.677",
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",