@ews-admin/global-design-system 1.1.27 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ews-admin/global-design-system",
3
- "version": "1.1.27",
3
+ "version": "1.6.0",
4
4
  "description": "EWS Global Design System - Reusable components for EWS applications",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -98,6 +98,8 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
98
98
  rightAddon,
99
99
  id,
100
100
  type = "text",
101
+ onChange,
102
+ onBlur,
101
103
  ...props
102
104
  },
103
105
  ref
@@ -112,6 +114,27 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
112
114
  const shouldShowPasswordToggle = showPasswordToggle && isPasswordInput;
113
115
  const actualType = isPasswordInput && showPassword ? "text" : type;
114
116
 
117
+ // Normalize spaces for text-like inputs
118
+ const shouldNormalize = type !== "password" && type !== "number" && type !== "checkbox";
119
+
120
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
121
+ if (shouldNormalize) {
122
+ e.target.value = e.target.value.replace(/^\s+/, "").replace(/\s{2,}/g, " ");
123
+ }
124
+ onChange?.(e);
125
+ };
126
+
127
+ const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
128
+ if (shouldNormalize && onChange) {
129
+ const trimmed = e.target.value.replace(/\s+$/, "");
130
+ if (trimmed !== e.target.value) {
131
+ e.target.value = trimmed;
132
+ onChange(e as unknown as React.ChangeEvent<HTMLInputElement>);
133
+ }
134
+ }
135
+ onBlur?.(e);
136
+ };
137
+
115
138
  // Country code dropdown state
116
139
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
117
140
  const dropdownRef = useRef<HTMLDivElement>(null);
@@ -313,6 +336,8 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
313
336
  className
314
337
  )}
315
338
  ref={ref}
339
+ onChange={handleChange}
340
+ onBlur={handleBlur}
316
341
  {...props}
317
342
  />
318
343
  {rightAddon && !rightIcon && !shouldShowPasswordToggle && (