@ews-admin/global-design-system 1.5.0 → 1.6.0
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/components/Input/Input.d.ts.map +1 -1
- package/dist/index.esm.js +20 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Input/Input.tsx +25 -0
package/dist/index.js
CHANGED
|
@@ -32545,7 +32545,7 @@ const UserIcon = ({ size = 24, color = "currentColor", className = "", ...props
|
|
|
32545
32545
|
return jsxRuntime.jsx(User, { size: size, color: color, className: className, ...props });
|
|
32546
32546
|
};
|
|
32547
32547
|
|
|
32548
|
-
const Input = React.forwardRef(({ className, variant = "default", size = "md", label, helperText, error, leftIcon, rightIcon, fullWidth = false, showPasswordToggle = false, required = false, countryCodeSelect, leftAddon, rightAddon, id, type = "text", ...props }, ref) => {
|
|
32548
|
+
const Input = React.forwardRef(({ className, variant = "default", size = "md", label, helperText, error, leftIcon, rightIcon, fullWidth = false, showPasswordToggle = false, required = false, countryCodeSelect, leftAddon, rightAddon, id, type = "text", onChange, onBlur, ...props }, ref) => {
|
|
32549
32549
|
const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
|
|
32550
32550
|
const hasError = Boolean(error);
|
|
32551
32551
|
const actualVariant = hasError ? "error" : variant;
|
|
@@ -32554,6 +32554,24 @@ const Input = React.forwardRef(({ className, variant = "default", size = "md", l
|
|
|
32554
32554
|
const isPasswordInput = type === "password";
|
|
32555
32555
|
const shouldShowPasswordToggle = showPasswordToggle && isPasswordInput;
|
|
32556
32556
|
const actualType = isPasswordInput && showPassword ? "text" : type;
|
|
32557
|
+
// Normalize spaces for text-like inputs
|
|
32558
|
+
const shouldNormalize = type !== "password" && type !== "number" && type !== "checkbox";
|
|
32559
|
+
const handleChange = (e) => {
|
|
32560
|
+
if (shouldNormalize) {
|
|
32561
|
+
e.target.value = e.target.value.replace(/^\s+/, "").replace(/\s{2,}/g, " ");
|
|
32562
|
+
}
|
|
32563
|
+
onChange?.(e);
|
|
32564
|
+
};
|
|
32565
|
+
const handleBlur = (e) => {
|
|
32566
|
+
if (shouldNormalize && onChange) {
|
|
32567
|
+
const trimmed = e.target.value.replace(/\s+$/, "");
|
|
32568
|
+
if (trimmed !== e.target.value) {
|
|
32569
|
+
e.target.value = trimmed;
|
|
32570
|
+
onChange(e);
|
|
32571
|
+
}
|
|
32572
|
+
}
|
|
32573
|
+
onBlur?.(e);
|
|
32574
|
+
};
|
|
32557
32575
|
// Country code dropdown state
|
|
32558
32576
|
const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);
|
|
32559
32577
|
const dropdownRef = React.useRef(null);
|
|
@@ -32604,7 +32622,7 @@ const Input = React.forwardRef(({ className, variant = "default", size = "md", l
|
|
|
32604
32622
|
countryCodeSelect.onChange(item.code);
|
|
32605
32623
|
setIsDropdownOpen(false);
|
|
32606
32624
|
}, className: cn("px-3 py-2 text-sm cursor-pointer transition-colors", isSelected && "bg-ews-primary text-white", !isSelected && "hover:bg-ews-gray-50"), children: [jsxRuntime.jsx("span", { className: "font-medium", children: item.code }), item.country && (jsxRuntime.jsx("span", { className: cn("ml-2 text-xs", isSelected ? "text-white/80" : "text-ews-gray-500"), children: item.country }))] }, item.code));
|
|
32607
|
-
}) }))] }) })), leftIcon && !countryCodeSelect && !leftAddon && (jsxRuntime.jsx("div", { className: "flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none", children: jsxRuntime.jsx("span", { className: cn("text-ews-gray-400", iconSizes[size]), children: leftIcon }) })), leftAddon && !countryCodeSelect && !leftIcon && (jsxRuntime.jsx("div", { className: "flex absolute inset-y-0 left-0 items-center pointer-events-none overflow-hidden rounded-l-md", children: jsxRuntime.jsx("span", { className: "flex items-center h-full px-3 text-sm font-medium whitespace-nowrap bg-ews-gray-50 border-r border-ews-gray-300 text-ews-gray-600", children: leftAddon }) })), jsxRuntime.jsx("input", { id: inputId, type: actualType, className: cn(baseStyles, variants[actualVariant], sizes[size], countryCodeSelect && "pl-24", leftIcon && !countryCodeSelect && !leftAddon && "pl-10", leftAddon && !countryCodeSelect && !leftIcon && "pl-16", (rightIcon || shouldShowPasswordToggle) && "pr-10", rightAddon && !rightIcon && !shouldShowPasswordToggle && "pr-16", className), ref: ref, ...props }), rightAddon && !rightIcon && !shouldShowPasswordToggle && (jsxRuntime.jsx("div", { className: "flex absolute inset-y-0 right-0 items-center pr-3 pointer-events-none", children: jsxRuntime.jsx("span", { className: "text-sm font-medium text-ews-gray-500", children: rightAddon }) })), rightIcon && !shouldShowPasswordToggle && (jsxRuntime.jsx("div", { className: "flex absolute inset-y-0 right-0 items-center pr-3 pointer-events-none", children: jsxRuntime.jsx("span", { className: cn("text-ews-gray-400", iconSizes[size]), children: rightIcon }) })), shouldShowPasswordToggle && (jsxRuntime.jsx("button", { type: "button", className: "flex absolute inset-y-0 right-0 items-center pr-3", onClick: () => setShowPassword(!showPassword), tabIndex: -1, children: jsxRuntime.jsx("span", { className: cn("transition-colors text-ews-gray-400 hover:text-ews-gray-600", iconSizes[size]), children: showPassword ? jsxRuntime.jsx(EyeOff, { size: 16 }) : jsxRuntime.jsx(Eye, { size: 16 }) }) }))] }), (error || helperText) && (jsxRuntime.jsx("p", { className: cn("text-sm", error ? "text-ews-error" : "text-ews-gray-500"), children: error || helperText }))] }));
|
|
32625
|
+
}) }))] }) })), leftIcon && !countryCodeSelect && !leftAddon && (jsxRuntime.jsx("div", { className: "flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none", children: jsxRuntime.jsx("span", { className: cn("text-ews-gray-400", iconSizes[size]), children: leftIcon }) })), leftAddon && !countryCodeSelect && !leftIcon && (jsxRuntime.jsx("div", { className: "flex absolute inset-y-0 left-0 items-center pointer-events-none overflow-hidden rounded-l-md", children: jsxRuntime.jsx("span", { className: "flex items-center h-full px-3 text-sm font-medium whitespace-nowrap bg-ews-gray-50 border-r border-ews-gray-300 text-ews-gray-600", children: leftAddon }) })), jsxRuntime.jsx("input", { id: inputId, type: actualType, className: cn(baseStyles, variants[actualVariant], sizes[size], countryCodeSelect && "pl-24", leftIcon && !countryCodeSelect && !leftAddon && "pl-10", leftAddon && !countryCodeSelect && !leftIcon && "pl-16", (rightIcon || shouldShowPasswordToggle) && "pr-10", rightAddon && !rightIcon && !shouldShowPasswordToggle && "pr-16", className), ref: ref, onChange: handleChange, onBlur: handleBlur, ...props }), rightAddon && !rightIcon && !shouldShowPasswordToggle && (jsxRuntime.jsx("div", { className: "flex absolute inset-y-0 right-0 items-center pr-3 pointer-events-none", children: jsxRuntime.jsx("span", { className: "text-sm font-medium text-ews-gray-500", children: rightAddon }) })), rightIcon && !shouldShowPasswordToggle && (jsxRuntime.jsx("div", { className: "flex absolute inset-y-0 right-0 items-center pr-3 pointer-events-none", children: jsxRuntime.jsx("span", { className: cn("text-ews-gray-400", iconSizes[size]), children: rightIcon }) })), shouldShowPasswordToggle && (jsxRuntime.jsx("button", { type: "button", className: "flex absolute inset-y-0 right-0 items-center pr-3", onClick: () => setShowPassword(!showPassword), tabIndex: -1, children: jsxRuntime.jsx("span", { className: cn("transition-colors text-ews-gray-400 hover:text-ews-gray-600", iconSizes[size]), children: showPassword ? jsxRuntime.jsx(EyeOff, { size: 16 }) : jsxRuntime.jsx(Eye, { size: 16 }) }) }))] }), (error || helperText) && (jsxRuntime.jsx("p", { className: cn("text-sm", error ? "text-ews-error" : "text-ews-gray-500"), children: error || helperText }))] }));
|
|
32608
32626
|
});
|
|
32609
32627
|
Input.displayName = "Input";
|
|
32610
32628
|
|