@ayseaistudio/ui-components 3.9.6 → 3.11.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.
@@ -11,6 +11,7 @@ interface Props {
11
11
  clearable?: boolean;
12
12
  text?: string;
13
13
  headerText?: string;
14
+ headerVariant?: "medium" | "bold";
14
15
  withHeader?: boolean;
15
16
  size?: "large" | "with-password-eye" | "medium" | "small" | "with-button";
16
17
  status?: "active" | "default" | "hover" | "alert" | "disabled";
@@ -19,6 +20,7 @@ interface Props {
19
20
  frameClassName?: string;
20
21
  isPassword?: boolean;
21
22
  value?: string;
23
+ noHoverBackground?: boolean;
22
24
  onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
23
25
  onClear?: () => void;
24
26
  onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
@@ -28,7 +30,7 @@ interface Props {
28
30
  onRequestPopupOpen?: (anchorEl: HTMLElement | null) => void;
29
31
  }
30
32
  export declare const InputField: {
31
- ({ withAlertIcon, withAlertMessage, leftIcon, rightIcon, defaultValue, alertText, clearable, text, headerText, withHeader, size, status, radius, className, frameClassName, isPassword, value, onChange, onClear, onFocus, onBlur, onKeyDown, selectFromPopup, onRequestPopupOpen, }: Props): React.JSX.Element;
33
+ ({ withAlertIcon, withAlertMessage, leftIcon, rightIcon, defaultValue, alertText, clearable, text, headerText, headerVariant, withHeader, size, status, radius, className, frameClassName, isPassword, value, noHoverBackground, onChange, onClear, onFocus, onBlur, onKeyDown, selectFromPopup, onRequestPopupOpen, }: Props): React.JSX.Element;
32
34
  propTypes: {
33
35
  withAlertIcon: PropTypes.Requireable<boolean>;
34
36
  withAlertMessage: PropTypes.Requireable<boolean>;
@@ -38,6 +40,7 @@ export declare const InputField: {
38
40
  withRightIcon: PropTypes.Requireable<boolean>;
39
41
  text: PropTypes.Requireable<string>;
40
42
  headerText: PropTypes.Requireable<string>;
43
+ headerVariant: PropTypes.Requireable<string>;
41
44
  withHeader: PropTypes.Requireable<boolean>;
42
45
  size: PropTypes.Requireable<string>;
43
46
  status: PropTypes.Requireable<string>;
@@ -55,6 +58,7 @@ export declare const InputField: {
55
58
  onClear: PropTypes.Requireable<(...args: any[]) => any>;
56
59
  selectFromPopup: PropTypes.Requireable<boolean>;
57
60
  onRequestPopupOpen: PropTypes.Requireable<(...args: any[]) => any>;
61
+ noHoverBackground: PropTypes.Requireable<boolean>;
58
62
  };
59
63
  };
60
64
  export {};
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import PropTypes from "prop-types";
3
3
  import React, { useEffect, useReducer, useRef, useState } from "react";
4
4
  import "./style.css";
5
- import { IconEyeOff, IconEye, IconX, IconAlertSquareRounded } from "@tabler/icons-react";
5
+ import { IconEyeOff, IconEye, IconX, IconAlertSquareRounded, IconInfoSquareRoundedFilled } from "@tabler/icons-react";
6
6
  const initialState = (size, status, radius) => ({
7
7
  size,
8
8
  status,
@@ -23,7 +23,7 @@ const reducer = (state, action) => {
23
23
  return state;
24
24
  }
25
25
  };
26
- export const InputField = ({ withAlertIcon = true, withAlertMessage = true, leftIcon, rightIcon, defaultValue = "", alertText = "Doldurulması zorunlu alan.", clearable = false, text = "Placeholder", headerText = "Label", withHeader = true, size = "large", status = "default", radius = "small", className, frameClassName, isPassword = false, value, onChange, onClear, onFocus, onBlur, onKeyDown, selectFromPopup = false, onRequestPopupOpen, }) => {
26
+ export const InputField = ({ withAlertIcon = true, withAlertMessage = true, leftIcon, rightIcon, defaultValue = "", alertText = "Doldurulması zorunlu alan.", clearable = false, text = "Placeholder", headerText = "Label", headerVariant = "medium", withHeader = true, size = "large", status = "default", radius = "small", className, frameClassName, isPassword = false, value, noHoverBackground = false, onChange, onClear, onFocus, onBlur, onKeyDown, selectFromPopup = false, onRequestPopupOpen, }) => {
27
27
  const [state, dispatch] = useReducer(reducer, initialState(size, status, radius));
28
28
  const [inputValue, setInputValue] = useState(defaultValue);
29
29
  const [isPasswordVisible, setIsPasswordVisible] = useState(false);
@@ -33,7 +33,6 @@ export const InputField = ({ withAlertIcon = true, withAlertMessage = true, left
33
33
  const handleInputChange = (event) => {
34
34
  const newValue = event.target.value;
35
35
  if (selectFromPopup) {
36
- // typing is disabled in select-from-popup mode
37
36
  return;
38
37
  }
39
38
  if (isControlled) {
@@ -73,7 +72,7 @@ export const InputField = ({ withAlertIcon = true, withAlertMessage = true, left
73
72
  return;
74
73
  onRequestPopupOpen?.(containerRef.current);
75
74
  };
76
- // selection is handled by parent when using external popup
75
+ const iconColor = getStatusColor(state.status);
77
76
  return (_jsxs("div", { className: `input-field size-2-${state.size} ${className}`, ref: containerRef, onMouseLeave: () => {
78
77
  if (hasValue && isFocused)
79
78
  return;
@@ -82,19 +81,28 @@ export const InputField = ({ withAlertIcon = true, withAlertMessage = true, left
82
81
  if (hasValue && isFocused)
83
82
  return;
84
83
  dispatch("mouse_enter");
85
- }, onClick: () => dispatch("click"), children: [withHeader && (_jsx("div", { className: `frame ${["active", "default", "disabled", "hover"].includes(state.status) ? frameClassName : ""}`, children: _jsx("div", { className: `label-2 ${state.status}`, children: headerText }) })), _jsxs("div", { className: `input-fields size-4-${state.size} status-0-${state.status}`, onClick: toggleDropdown, children: [leftIcon && React.cloneElement(leftIcon, { color: getStatusColor(state.status) }), _jsx("input", { type: isPassword ? (isPasswordVisible ? "text" : "password") : "text", placeholder: text, value: currentValue, onChange: handleInputChange, onFocus: handleFocusInternal, onBlur: handleBlurInternal, onKeyDown: onKeyDown, className: `input-field-placeholder size-${state.size} ${state.status === "alert" ? "alert" : ""}`, style: {
84
+ }, onClick: () => dispatch("click"), children: [withHeader && (_jsx("div", { className: `frame ${["active", "default", "disabled", "hover"].includes(state.status) ? frameClassName : ""}`, children: _jsx("div", { className: `label-2 label-2-${headerVariant} ${state.status}`, children: headerText }) })), _jsxs("div", { className: `input-fields size-4-${state.size} status-0-${state.status} ${noHoverBackground ? "no-hover-bg" : ""}`, onClick: toggleDropdown, children: [leftIcon &&
85
+ React.cloneElement(leftIcon, {
86
+ color: iconColor,
87
+ style: { ...(leftIcon.props?.style || {}), color: iconColor },
88
+ }), _jsx("input", { type: isPassword ? (isPasswordVisible ? "text" : "password") : "text", placeholder: text, value: currentValue, onChange: handleInputChange, onFocus: handleFocusInternal, onBlur: handleBlurInternal, onKeyDown: onKeyDown, className: `input-field-placeholder size-${state.size} ${state.status === "alert" ? "alert" : ""}`, style: {
86
89
  backgroundColor: "transparent",
87
90
  border: "none",
88
91
  flex: 1,
89
92
  minWidth: 0,
90
93
  outline: "none",
91
94
  padding: "0",
92
- }, readOnly: selectFromPopup }), clearable && !!currentValue && currentValue.length > 0 && (_jsx(IconX, { stroke: 1.5, className: "button-clear", color: getStatusColor(state.status), onClick: handleClear })), rightIcon && isPassword && (isPasswordVisible ? (_jsx(IconEyeOff, { stroke: 1.5, className: "button-password-eye", color: getStatusColor(state.status), onClick: () => setIsPasswordVisible(!isPasswordVisible) })) : (_jsx(IconEye, { stroke: 1.5, className: "button-password-eye", color: getStatusColor(state.status), onClick: () => setIsPasswordVisible(!isPasswordVisible) }))), rightIcon && React.cloneElement(rightIcon, { color: getStatusColor(state.status) })] }), false, state.status === "alert" && withAlertMessage && (_jsxs("div", { className: "frame-2", children: [withAlertIcon && _jsx(IconAlertSquareRounded, { size: 20, stroke: 1.5 }), _jsx("div", { className: "doldurulmas-zorunlu", children: alertText })] }))] }));
95
+ }, readOnly: selectFromPopup }), clearable && !!currentValue && currentValue.length > 0 && (_jsx(IconX, { stroke: 1.5, className: "button-clear", color: getStatusColor(state.status), onClick: handleClear })), rightIcon && isPassword && (isPasswordVisible ? (_jsx(IconEyeOff, { stroke: 1.5, className: "button-password-eye", color: getStatusColor(state.status), onClick: () => setIsPasswordVisible(!isPasswordVisible) })) : (_jsx(IconEye, { stroke: 1.5, className: "button-password-eye", color: getStatusColor(state.status), onClick: () => setIsPasswordVisible(!isPasswordVisible) }))), rightIcon &&
96
+ React.cloneElement(rightIcon, {
97
+ color: iconColor,
98
+ style: { ...(rightIcon.props?.style || {}), color: iconColor },
99
+ })] }), false, state.status === "alert" && withAlertMessage && (_jsxs("div", { className: "frame-2", children: [withAlertIcon &&
100
+ (noHoverBackground ? (_jsx(IconInfoSquareRoundedFilled, { size: 12, className: "icons-1019", color: "rgba(255, 55, 55, 1)" })) : (_jsx(IconAlertSquareRounded, { size: 20, stroke: 1.5 }))), _jsx("div", { className: `doldurulmas-zorunlu ${noHoverBackground ? "doldurulmas-zorunlu-variant" : ""}`, children: alertText })] }))] }));
93
101
  };
94
102
  const getStatusColor = (status) => {
95
103
  switch (status) {
96
104
  case "hover":
97
- return "rgba(136, 136, 136, 1)";
105
+ return "rgba(48, 48, 48, 1)";
98
106
  case "active":
99
107
  return "rgba(48, 48, 48, 1)";
100
108
  case "disabled":
@@ -115,6 +123,7 @@ InputField.propTypes = {
115
123
  withRightIcon: PropTypes.bool,
116
124
  text: PropTypes.string,
117
125
  headerText: PropTypes.string,
126
+ headerVariant: PropTypes.oneOf(["medium", "bold"]),
118
127
  withHeader: PropTypes.bool,
119
128
  size: PropTypes.oneOf(["large", "with-password-eye", "medium", "small", "with-button"]),
120
129
  status: PropTypes.oneOf(["active", "default", "hover", "alert", "disabled"]),
@@ -132,4 +141,5 @@ InputField.propTypes = {
132
141
  onClear: PropTypes.func,
133
142
  selectFromPopup: PropTypes.bool,
134
143
  onRequestPopupOpen: PropTypes.func,
144
+ noHoverBackground: PropTypes.bool,
135
145
  };
@@ -12,7 +12,7 @@
12
12
  flex: 0 0 auto;
13
13
  gap: 10px;
14
14
  justify-content: center;
15
- padding: 0px 8px;
15
+ padding: 0px 4px;
16
16
  position: relative;
17
17
  }
18
18
 
@@ -28,6 +28,15 @@
28
28
  position: relative;
29
29
  }
30
30
 
31
+ .input-field .label-2-bold {
32
+ font-family: var(--b2-bold-font-family);
33
+ font-size: var(--b2-bold-font-size);
34
+ font-style: var(--b2-bold-font-style);
35
+ font-weight: var(--b2-bold-font-weight);
36
+ letter-spacing: var(--b2-bold-letter-spacing);
37
+ line-height: var(--b2-bold-line-height);
38
+ }
39
+
31
40
  .input-field .input-fields {
32
41
  align-items: center;
33
42
  border-radius: 12px;
@@ -173,6 +182,10 @@
173
182
  width: fit-content;
174
183
  }
175
184
 
185
+ .input-field .doldurulmas-zorunlu-variant {
186
+ color: rgba(255, 55, 55, 1);
187
+ }
188
+
176
189
  .input-field.size-2-with-password-eye {
177
190
  display: inline-flex;
178
191
  }
@@ -267,6 +280,12 @@
267
280
  border-color: #2424241a;
268
281
  }
269
282
 
283
+ .input-field .input-fields.status-0-hover.no-hover-bg,
284
+ .input-field .input-fields.status-0-active.no-hover-bg {
285
+ background-color: transparent;
286
+ border-color: #2424244c;
287
+ }
288
+
270
289
  .input-field.size-2-with-password-eye .frame {
271
290
  width: 241px;
272
291
  }
@@ -1,19 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import PropTypes from "prop-types";
3
- import { useEffect, useReducer, useState } from "react";
3
+ import React, { useEffect, useReducer, useState } from "react";
4
4
  import "./style.css";
5
- import { IconLayoutDashboard, IconUser, IconPassword } from "@tabler/icons-react";
5
+ import { IconLayoutDashboard, IconUser, IconPassword, IconEye, IconEyeOff } from "@tabler/icons-react";
6
6
  export const LoginInput = ({ withIcon = true, placeholder = "Enter text", status = "default", className = "", icon = _jsx(IconLayoutDashboard, { size: 20, color: "#B0B0B0" }), value = "", onChange, inputType = "text", version, singleChar = false, inputRef, onKeyDown, }) => {
7
- let finalIcon = icon;
8
7
  let finalPlaceholder = placeholder;
9
8
  let finalInputType = inputType;
10
9
  if (version === "username") {
11
- finalIcon = _jsx(IconUser, { size: 20, color: "#B0B0B0" });
12
10
  finalPlaceholder = "Kullanıcı Adı";
13
11
  finalInputType = "text";
14
12
  }
15
13
  else if (version === "password") {
16
- finalIcon = _jsx(IconPassword, { size: 20, color: "#B0B0B0" });
17
14
  finalPlaceholder = "Şifre";
18
15
  finalInputType = "password";
19
16
  }
@@ -21,16 +18,42 @@ export const LoginInput = ({ withIcon = true, placeholder = "Enter text", status
21
18
  const [isFocused, setIsFocused] = useState(false);
22
19
  const [inputValue, setInputValue] = useState(value);
23
20
  const [actualType, setActualType] = useState("text");
21
+ const [showPassword, setShowPassword] = useState(false);
22
+ const hasPasswordToggle = version === "password";
23
+ const autoCompleteType = version === "username"
24
+ ? "username"
25
+ : version === "password"
26
+ ? "current-password"
27
+ : "off";
28
+ const inputName = version === "username"
29
+ ? "username"
30
+ : version === "password"
31
+ ? "password"
32
+ : "login-input";
33
+ const isActive = isFocused || inputValue;
34
+ const iconColor = isActive || state.status === "hover" ? "#888888" : "#B0B0B0";
35
+ let finalIcon = icon;
36
+ if (version === "username") {
37
+ finalIcon = _jsx(IconUser, { size: 20, color: iconColor });
38
+ }
39
+ else if (version === "password") {
40
+ finalIcon = _jsx(IconPassword, { size: 20, color: iconColor });
41
+ }
42
+ else if (icon && React.isValidElement(icon) && icon.type === IconLayoutDashboard) {
43
+ finalIcon = _jsx(IconLayoutDashboard, { size: 20, color: iconColor });
44
+ }
45
+ else if (icon && React.isValidElement(icon)) {
46
+ finalIcon = React.cloneElement(icon, { color: iconColor });
47
+ }
24
48
  useEffect(() => {
25
49
  if (version === "password") {
26
50
  const timer = setTimeout(() => {
27
- setActualType("password");
28
- }, 100); // DOM renderlandıktan kısa süre sonra değiştir
51
+ setActualType(showPassword ? "text" : "password");
52
+ }, 100);
29
53
  return () => clearTimeout(timer);
30
54
  }
31
- }, [version]);
55
+ }, [version, showPassword]);
32
56
  useEffect(() => {
33
- // Sync internal state when external value changes
34
57
  setInputValue(value || "");
35
58
  }, [value]);
36
59
  const handleInputChange = (e) => {
@@ -55,13 +78,16 @@ export const LoginInput = ({ withIcon = true, placeholder = "Enter text", status
55
78
  if (!inputValue)
56
79
  dispatch("blur");
57
80
  };
81
+ const togglePasswordVisibility = () => {
82
+ setShowPassword(!showPassword);
83
+ };
58
84
  return (_jsxs("div", { className: `login-input ${state.status} ${className}`, onMouseLeave: () => {
59
85
  if (state.status !== "selected")
60
86
  dispatch("mouse_leave");
61
87
  }, onMouseEnter: () => {
62
88
  if (state.status !== "selected")
63
89
  dispatch("mouse_enter");
64
- }, children: [_jsxs("div", { className: `placeholder-container ${isFocused || inputValue ? "active" : ""}`, children: [withIcon && _jsx("span", { className: "icon-container", children: finalIcon }), _jsx("label", { className: "placeholder", htmlFor: "login-input", children: finalPlaceholder })] }), _jsx("input", { id: `login-input-${version}`, className: "input-field", type: version === "password" ? actualType : finalInputType, value: inputValue, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: onKeyDown, autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", name: `input-${version}-${Math.random().toString(36).substring(2, 15)}`, maxLength: singleChar ? 1 : undefined, ref: inputRef })] }));
90
+ }, children: [_jsxs("div", { className: `placeholder-container ${isFocused || inputValue ? "active" : ""}`, children: [withIcon && _jsx("span", { className: "icon-container", children: finalIcon }), _jsx("label", { className: "placeholder", htmlFor: "login-input", children: finalPlaceholder })] }), _jsx("input", { id: `login-input-${version}`, className: `input-field ${hasPasswordToggle ? "with-password-toggle" : ""}`, type: version === "password" ? actualType : finalInputType, value: inputValue, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: onKeyDown, autoComplete: autoCompleteType, autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", name: inputName, maxLength: singleChar ? 1 : undefined, ref: inputRef }), hasPasswordToggle && (_jsx("button", { type: "button", className: "password-toggle", onClick: togglePasswordVisibility, tabIndex: 0, children: showPassword ? (_jsx(IconEyeOff, { size: 24, strokeWidth: 1.5 })) : (_jsx(IconEye, { size: 24, strokeWidth: 1.5 })) }))] }));
65
91
  };
66
92
  function reducer(state, action) {
67
93
  switch (action) {
@@ -19,6 +19,19 @@
19
19
  background-color: rgba(36, 36, 36, 0.05);
20
20
  }
21
21
 
22
+ .login-input:hover .placeholder {
23
+ color: #888888;
24
+ }
25
+
26
+ .login-input:hover .icon-container {
27
+ color: #888888;
28
+ }
29
+
30
+ .login-input:hover .icon-container svg {
31
+ color: #888888;
32
+ stroke: #888888;
33
+ }
34
+
22
35
  .placeholder-container {
23
36
  display: flex;
24
37
  align-items: center;
@@ -53,7 +66,7 @@
53
66
  }
54
67
 
55
68
  .placeholder-container.active .placeholder {
56
- font-size: 12px; /* Placeholder yazı boyutu küçültüldü */
69
+ font-size: 12px;
57
70
  color: #888888;
58
71
  }
59
72
 
@@ -65,7 +78,12 @@
65
78
  width: 100%;
66
79
  background-color: transparent;
67
80
  color: #242424;
68
- margin: 0; /* Varsayılan margin'i kaldır */
81
+ margin-top: 6px;
82
+ padding-right: 0;
83
+ }
84
+
85
+ .input-field.with-password-toggle {
86
+ padding-right: 40px;
69
87
  }
70
88
 
71
89
  .input-field::placeholder {
@@ -106,4 +124,78 @@
106
124
 
107
125
  .placeholder-container.active .icon-container {
108
126
  transform: scale(0.7) translateY(-1px); /* Küçültüp yukarı taşı */
127
+ }
128
+
129
+ .login-input.selected .icon-container,
130
+ .login-input.selected:hover .icon-container {
131
+ color: #888888;
132
+ }
133
+
134
+ .login-input.selected .icon-container svg,
135
+ .login-input.selected:hover .icon-container svg {
136
+ color: #888888;
137
+ stroke: #888888;
138
+ }
139
+
140
+ .password-toggle {
141
+ position: absolute;
142
+ right: 16px;
143
+ top: 54%;
144
+ transform: translateY(-50%);
145
+ background: none;
146
+ border: none;
147
+ cursor: pointer;
148
+ padding: 4px;
149
+ display: flex;
150
+ align-items: center;
151
+ justify-content: center;
152
+ transition: opacity 0.2s ease;
153
+ z-index: 1;
154
+ }
155
+
156
+ .password-toggle:hover {
157
+ opacity: 0.7;
158
+ }
159
+
160
+ .password-toggle:focus {
161
+ outline: none;
162
+ opacity: 0.7;
163
+ }
164
+
165
+ .password-toggle svg {
166
+ color: #b0b0b0;
167
+ stroke: #b0b0b0;
168
+ transition: color 0.2s ease, stroke 0.2s ease;
169
+ }
170
+
171
+ .login-input:hover .password-toggle svg,
172
+ .login-input.selected .password-toggle svg,
173
+ .login-input.selected:hover .password-toggle svg {
174
+ color: #888888;
175
+ stroke: #888888;
176
+ }
177
+
178
+ .input-field:-webkit-autofill,
179
+ .input-field:-webkit-autofill:hover,
180
+ .input-field:-webkit-autofill:focus {
181
+ -webkit-text-fill-color: #242424;
182
+ -webkit-box-shadow: 0 0 0 1000px transparent inset;
183
+ box-shadow: 0 0 0 1000px transparent inset;
184
+ transition: background-color 9999s ease-in-out 0s;
185
+ }
186
+
187
+ .login-input:has(.input-field:-webkit-autofill),
188
+ .login-input:has(.input-field:autofill) {
189
+ border-color: rgba(36, 36, 36, 0.3);
190
+ background-color: rgba(36, 36, 36, 0.05);
191
+ }
192
+
193
+ .login-input:has(.input-field:-webkit-autofill) .placeholder,
194
+ .login-input:has(.input-field:autofill) .placeholder,
195
+ .login-input:has(.input-field:-webkit-autofill) .icon-container svg,
196
+ .login-input:has(.input-field:autofill) .icon-container svg,
197
+ .login-input:has(.input-field:-webkit-autofill) .password-toggle svg,
198
+ .login-input:has(.input-field:autofill) .password-toggle svg {
199
+ color: #888888;
200
+ stroke: #888888;
109
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ayseaistudio/ui-components",
3
- "version": "3.9.6",
3
+ "version": "3.11.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",