@ayseaistudio/ui-components 3.10.0 → 3.11.1
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
|
-
|
|
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}
|
|
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 &&
|
|
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(
|
|
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
|
|
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
|
}
|