nucleus-core-ts 0.8.6 → 0.8.8
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/client.js +1 -1
- package/dist/dist/index.d.ts +475 -12
- package/dist/fe/components/AbstractAnimatedBackground/index.js +437 -0
- package/dist/fe/components/AuthorizationPage/components/AuthorizationPage.js +841 -0
- package/dist/fe/components/AuthorizationPage/components/ClaimList.js +100 -0
- package/dist/fe/components/AuthorizationPage/components/RoleClaimEditor.js +232 -0
- package/dist/fe/components/AuthorizationPage/components/RoleList.js +115 -0
- package/dist/fe/components/AuthorizationPage/index.js +6 -0
- package/dist/fe/components/AuthorizationPage/store/index.js +117 -0
- package/dist/fe/components/AuthorizationPage/theme/index.js +137 -0
- package/dist/fe/components/AuthorizationPage/types/index.js +1 -0
- package/dist/fe/components/Button/components/Button.js +158 -0
- package/dist/fe/components/Button/components/ButtonSpinner.js +52 -0
- package/dist/fe/components/Button/index.js +3 -0
- package/dist/fe/components/Button/theme/index.js +186 -0
- package/dist/fe/components/Button/types/index.js +1 -0
- package/dist/fe/components/Button/utils/cn.js +5 -0
- package/dist/fe/components/Captcha/components/Captcha.js +311 -0
- package/dist/fe/components/Captcha/index.js +2 -0
- package/dist/fe/components/Captcha/theme.js +52 -0
- package/dist/fe/components/Captcha/types.js +1 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordForm.js +242 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordHeader.js +39 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordPage.js +60 -0
- package/dist/fe/components/ChangePasswordPage/index.js +5 -0
- package/dist/fe/components/ChangePasswordPage/store/index.js +44 -0
- package/dist/fe/components/ChangePasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ChangePasswordPage/types/index.js +1 -0
- package/dist/fe/components/Checkbox/components/Checkbox.js +115 -0
- package/dist/fe/components/Checkbox/components/CheckboxIcon.js +119 -0
- package/dist/fe/components/Checkbox/components/SwitchTrack.js +178 -0
- package/dist/fe/components/Checkbox/index.js +4 -0
- package/dist/fe/components/Checkbox/theme/index.js +221 -0
- package/dist/fe/components/Checkbox/types/index.js +1 -0
- package/dist/fe/components/Checkbox/utils/cn.js +5 -0
- package/dist/fe/components/DataTable/DataTable.js +225 -0
- package/dist/fe/components/DataTable/components/ActionCell.js +26 -0
- package/dist/fe/components/DataTable/components/DataCell.js +76 -0
- package/dist/fe/components/DataTable/components/EditableCell.js +221 -0
- package/dist/fe/components/DataTable/components/EmptyState.js +29 -0
- package/dist/fe/components/DataTable/components/HeaderCell.js +64 -0
- package/dist/fe/components/DataTable/components/InfiniteScrollTrigger.js +66 -0
- package/dist/fe/components/DataTable/components/LoadingSpinner.js +19 -0
- package/dist/fe/components/DataTable/components/ResizeHandle.js +41 -0
- package/dist/fe/components/DataTable/components/SelectionCell.js +105 -0
- package/dist/fe/components/DataTable/components/SkeletonRow.js +56 -0
- package/dist/fe/components/DataTable/components/SkeletonTable.js +83 -0
- package/dist/fe/components/DataTable/components/SortIcon.js +39 -0
- package/dist/fe/components/DataTable/components/TableHeader.js +49 -0
- package/dist/fe/components/DataTable/components/TableRow.js +118 -0
- package/dist/fe/components/DataTable/components/index.js +14 -0
- package/dist/fe/components/DataTable/hooks/index.js +2 -0
- package/dist/fe/components/DataTable/hooks/useAutoFitColumn.js +23 -0
- package/dist/fe/components/DataTable/hooks/useResizeColumn.js +122 -0
- package/dist/fe/components/DataTable/index.js +3 -0
- package/dist/fe/components/DataTable/store/index.js +97 -0
- package/dist/fe/components/DataTable/theme/index.js +144 -0
- package/dist/fe/components/DataTable/types/index.js +1 -0
- package/dist/fe/components/DataTable/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/components/CalendarGrid.js +95 -0
- package/dist/fe/components/DatePicker/components/CalendarHeader.js +152 -0
- package/dist/fe/components/DatePicker/components/DatePicker.js +381 -0
- package/dist/fe/components/DatePicker/components/MonthYearSelector.js +93 -0
- package/dist/fe/components/DatePicker/index.js +7 -0
- package/dist/fe/components/DatePicker/locales/index.js +1113 -0
- package/dist/fe/components/DatePicker/theme/index.js +315 -0
- package/dist/fe/components/DatePicker/types/index.js +1 -0
- package/dist/fe/components/DatePicker/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/utils/date.js +132 -0
- package/dist/fe/components/DevicesPage/components/DeviceCard.js +251 -0
- package/dist/fe/components/DevicesPage/components/DevicesHeader.js +42 -0
- package/dist/fe/components/DevicesPage/components/DevicesPage.js +450 -0
- package/dist/fe/components/DevicesPage/index.js +5 -0
- package/dist/fe/components/DevicesPage/store/index.js +55 -0
- package/dist/fe/components/DevicesPage/theme/index.js +131 -0
- package/dist/fe/components/DevicesPage/types/index.js +1 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordForm.js +214 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordHeader.js +42 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordPage.js +59 -0
- package/dist/fe/components/ForgotPasswordPage/index.js +5 -0
- package/dist/fe/components/ForgotPasswordPage/store/index.js +28 -0
- package/dist/fe/components/ForgotPasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ForgotPasswordPage/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/components/FormBuilder.js +156 -0
- package/dist/fe/components/FormBuilder/components/FormField.js +218 -0
- package/dist/fe/components/FormBuilder/hooks/useFormBuilder.js +152 -0
- package/dist/fe/components/FormBuilder/index.js +4 -0
- package/dist/fe/components/FormBuilder/theme/index.js +134 -0
- package/dist/fe/components/FormBuilder/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/utils/cn.js +5 -0
- package/dist/fe/components/FormBuilder/utils/fieldMapping.js +216 -0
- package/dist/fe/components/FormBuilder/utils/validation.js +78 -0
- package/dist/fe/components/LoginPage/components/LoginForm.js +214 -0
- package/dist/fe/components/LoginPage/components/LoginHeader.js +24 -0
- package/dist/fe/components/LoginPage/components/LoginPage.js +138 -0
- package/dist/fe/components/LoginPage/index.js +5 -0
- package/dist/fe/components/LoginPage/store/index.js +59 -0
- package/dist/fe/components/LoginPage/theme/index.js +98 -0
- package/dist/fe/components/LoginPage/types/index.js +1 -0
- package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.js +200 -0
- package/dist/fe/components/MagicLinkVerifyPage/index.js +3 -0
- package/dist/fe/components/MagicLinkVerifyPage/store.js +20 -0
- package/dist/fe/components/MagicLinkVerifyPage/theme.js +36 -0
- package/dist/fe/components/MagicLinkVerifyPage/types.js +1 -0
- package/dist/fe/components/NucleusEntityShowcase.js +1409 -0
- package/dist/fe/components/NucleusTextInput/components/FloatingLabel.js +56 -0
- package/dist/fe/components/NucleusTextInput/components/InputIcons.js +258 -0
- package/dist/fe/components/NucleusTextInput/components/NucleusTextInput.js +321 -0
- package/dist/fe/components/NucleusTextInput/components/PasswordStrengthIndicator.js +104 -0
- package/dist/fe/components/NucleusTextInput/components/TypewriterText.js +56 -0
- package/dist/fe/components/NucleusTextInput/index.js +7 -0
- package/dist/fe/components/NucleusTextInput/theme/index.js +121 -0
- package/dist/fe/components/NucleusTextInput/types/index.js +1 -0
- package/dist/fe/components/NucleusTextInput/utils/cn.js +5 -0
- package/dist/fe/components/NucleusTextInput/utils/format.js +62 -0
- package/dist/fe/components/NucleusTextInput/utils/validation.js +191 -0
- package/dist/fe/components/ProfilePage/components/AddressCard.js +196 -0
- package/dist/fe/components/ProfilePage/components/PhoneCard.js +206 -0
- package/dist/fe/components/ProfilePage/components/ProfileHeader.js +150 -0
- package/dist/fe/components/ProfilePage/components/ProfilePage.js +1336 -0
- package/dist/fe/components/ProfilePage/index.js +6 -0
- package/dist/fe/components/ProfilePage/store/index.js +115 -0
- package/dist/fe/components/ProfilePage/theme/index.js +168 -0
- package/dist/fe/components/ProfilePage/types/index.js +1 -0
- package/dist/fe/components/RangePicker/components/RangePicker.js +338 -0
- package/dist/fe/components/RangePicker/components/RangeThumb.js +68 -0
- package/dist/fe/components/RangePicker/components/RangeTooltip.js +45 -0
- package/dist/fe/components/RangePicker/components/RangeTrack.js +32 -0
- package/dist/fe/components/RangePicker/index.js +5 -0
- package/dist/fe/components/RangePicker/theme/index.js +88 -0
- package/dist/fe/components/RangePicker/types/index.js +1 -0
- package/dist/fe/components/RangePicker/utils/cn.js +3 -0
- package/dist/fe/components/RegisterPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/RegisterPage/components/RegisterForm.js +322 -0
- package/dist/fe/components/RegisterPage/components/RegisterHeader.js +23 -0
- package/dist/fe/components/RegisterPage/components/RegisterPage.js +85 -0
- package/dist/fe/components/RegisterPage/index.js +6 -0
- package/dist/fe/components/RegisterPage/store/index.js +106 -0
- package/dist/fe/components/RegisterPage/theme/index.js +128 -0
- package/dist/fe/components/RegisterPage/types/index.js +1 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordForm.js +347 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordHeader.js +42 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordPage.js +61 -0
- package/dist/fe/components/ResetPasswordPage/index.js +5 -0
- package/dist/fe/components/ResetPasswordPage/store/index.js +36 -0
- package/dist/fe/components/ResetPasswordPage/theme/index.js +99 -0
- package/dist/fe/components/ResetPasswordPage/types/index.js +1 -0
- package/dist/fe/components/SearchBox/components/SearchBox.js +271 -0
- package/dist/fe/components/SearchBox/components/SearchBoxDropdown.js +87 -0
- package/dist/fe/components/SearchBox/index.js +5 -0
- package/dist/fe/components/SearchBox/theme/index.js +184 -0
- package/dist/fe/components/SearchBox/types/index.js +1 -0
- package/dist/fe/components/SearchBox/utils/cn.js +5 -0
- package/dist/fe/components/SearchBox/utils/debounce.js +22 -0
- package/dist/fe/components/SearchBox/utils/sanitize.js +48 -0
- package/dist/fe/components/SelectBox/components/SelectBox.js +364 -0
- package/dist/fe/components/SelectBox/components/SelectDropdown.js +92 -0
- package/dist/fe/components/SelectBox/components/SelectOptionItem.js +43 -0
- package/dist/fe/components/SelectBox/components/SelectTrigger.js +22 -0
- package/dist/fe/components/SelectBox/index.js +5 -0
- package/dist/fe/components/SelectBox/theme/index.js +98 -0
- package/dist/fe/components/SelectBox/types/index.js +1 -0
- package/dist/fe/components/SelectBox/utils/cn.js +3 -0
- package/dist/fe/components/SetPasswordPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordForm.js +142 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordHeader.js +23 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordPage.js +263 -0
- package/dist/fe/components/SetPasswordPage/index.js +7 -0
- package/dist/fe/components/SetPasswordPage/store/index.js +79 -0
- package/dist/fe/components/SetPasswordPage/theme/index.js +98 -0
- package/dist/fe/components/SetPasswordPage/types/index.js +12 -0
- package/dist/fe/components/UsersPage/components/InviteUserModal.js +262 -0
- package/dist/fe/components/UsersPage/components/Pagination.js +147 -0
- package/dist/fe/components/UsersPage/components/RoleAssignmentModal.js +186 -0
- package/dist/fe/components/UsersPage/components/StatsCards.js +124 -0
- package/dist/fe/components/UsersPage/components/UserDetailDrawer.js +444 -0
- package/dist/fe/components/UsersPage/components/UserFilters.js +142 -0
- package/dist/fe/components/UsersPage/components/UserListItem.js +125 -0
- package/dist/fe/components/UsersPage/components/UserListSkeleton.js +40 -0
- package/dist/fe/components/UsersPage/components/UsersPage.js +556 -0
- package/dist/fe/components/UsersPage/index.js +10 -0
- package/dist/fe/components/UsersPage/store/index.js +151 -0
- package/dist/fe/components/UsersPage/theme/index.js +231 -0
- package/dist/fe/components/UsersPage/types/index.js +1 -0
- package/dist/fe/components/VerifyEmailPage/components/VerifyEmailPage.js +290 -0
- package/dist/fe/components/VerifyEmailPage/index.js +3 -0
- package/dist/fe/components/VerifyEmailPage/store/index.js +45 -0
- package/dist/fe/components/VerifyEmailPage/theme/index.js +52 -0
- package/dist/fe/components/VerifyEmailPage/types/index.js +1 -0
- package/dist/fe/hooks/useNucleusEntity.js +247 -0
- package/dist/fe/index.js +28 -110
- package/dist/fe/types/index.js +1 -0
- package/dist/fe/utils/cn.js +5 -0
- package/dist/fe/utils/columnUtils.js +189 -0
- package/dist/fe/utils/endpointKeys.js +44 -0
- package/dist/index.js +1 -1
- package/dist/nucleus.config.d.ts +3 -0
- package/dist/src/Client/Proxy/httpProxy.js +1 -0
- package/dist/src/Client/Proxy/index.js +1 -1
- package/dist/src/Client/Proxy/server.js +1 -0
- package/dist/src/Client/Proxy/types.js +1 -0
- package/dist/src/Client/Proxy/utils.js +1 -0
- package/dist/src/Client/Proxy/wsProxy.js +1 -0
- package/package.json +1 -1
- package/scripts/build.ts +78 -8
- package/dist/dist/index-0yyw12k6.d.ts +0 -8
- package/dist/dist/index-tv67j5qd.d.ts +0 -488
- package/dist/index-0yyw12k6.js +0 -1
- package/dist/index-tv67j5qd.js +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useGSAP } from "@gsap/react";
|
|
4
|
+
import gsap from "gsap";
|
|
5
|
+
import { useRef } from "react";
|
|
6
|
+
import { nucleusTextInputTheme } from "../theme";
|
|
7
|
+
import { cn } from "../utils/cn";
|
|
8
|
+
gsap.registerPlugin(useGSAP);
|
|
9
|
+
export function FloatingLabel({ label, isFloated, isFocused, hasError, isDisabled, hasLeftIcon, className }) {
|
|
10
|
+
const labelRef = useRef(null);
|
|
11
|
+
const theme = nucleusTextInputTheme.label;
|
|
12
|
+
const animConfig = nucleusTextInputTheme.animation.label;
|
|
13
|
+
useGSAP(()=>{
|
|
14
|
+
if (!labelRef.current) return;
|
|
15
|
+
if (isFloated) {
|
|
16
|
+
gsap.to(labelRef.current, {
|
|
17
|
+
y: animConfig.floatY,
|
|
18
|
+
x: hasLeftIcon ? -20 : 0,
|
|
19
|
+
scale: animConfig.floatScale,
|
|
20
|
+
duration: animConfig.duration,
|
|
21
|
+
ease: animConfig.ease
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
gsap.to(labelRef.current, {
|
|
25
|
+
y: 0,
|
|
26
|
+
x: 0,
|
|
27
|
+
scale: 1,
|
|
28
|
+
duration: animConfig.duration,
|
|
29
|
+
ease: animConfig.ease
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, [
|
|
33
|
+
isFloated,
|
|
34
|
+
hasLeftIcon
|
|
35
|
+
]);
|
|
36
|
+
const getColorClass = ()=>{
|
|
37
|
+
if (isDisabled) return theme.states.disabled.color;
|
|
38
|
+
if (hasError) return theme.states.error.color;
|
|
39
|
+
if (isFocused) return theme.states.focused.color;
|
|
40
|
+
if (isFloated) return theme.states.floated.color;
|
|
41
|
+
return theme.states.inactive.color;
|
|
42
|
+
};
|
|
43
|
+
const getBackgroundClass = ()=>{
|
|
44
|
+
if (isFloated) return theme.states.floated.background;
|
|
45
|
+
return theme.states.inactive.background;
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/ _jsx("span", {
|
|
48
|
+
ref: labelRef,
|
|
49
|
+
className: cn(theme.base, getBackgroundClass(), hasLeftIcon ? "left-9 top-1/2 origin-left" : "left-3 top-1/2 origin-left", getColorClass(), className),
|
|
50
|
+
style: {
|
|
51
|
+
transform: "translateY(-50%)"
|
|
52
|
+
},
|
|
53
|
+
"aria-hidden": "true",
|
|
54
|
+
children: label
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
export function MailIcon({ className }) {
|
|
5
|
+
return /*#__PURE__*/ _jsxs("svg", {
|
|
6
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
7
|
+
viewBox: "0 0 24 24",
|
|
8
|
+
fill: "none",
|
|
9
|
+
stroke: "currentColor",
|
|
10
|
+
strokeWidth: "2",
|
|
11
|
+
strokeLinecap: "round",
|
|
12
|
+
strokeLinejoin: "round",
|
|
13
|
+
className: cn("h-5 w-5", className),
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
children: [
|
|
16
|
+
/*#__PURE__*/ _jsx("rect", {
|
|
17
|
+
width: "20",
|
|
18
|
+
height: "16",
|
|
19
|
+
x: "2",
|
|
20
|
+
y: "4",
|
|
21
|
+
rx: "2"
|
|
22
|
+
}),
|
|
23
|
+
/*#__PURE__*/ _jsx("path", {
|
|
24
|
+
d: "m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"
|
|
25
|
+
})
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export function LockIcon({ className }) {
|
|
30
|
+
return /*#__PURE__*/ _jsxs("svg", {
|
|
31
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
32
|
+
viewBox: "0 0 24 24",
|
|
33
|
+
fill: "none",
|
|
34
|
+
stroke: "currentColor",
|
|
35
|
+
strokeWidth: "2",
|
|
36
|
+
strokeLinecap: "round",
|
|
37
|
+
strokeLinejoin: "round",
|
|
38
|
+
className: cn("h-5 w-5", className),
|
|
39
|
+
"aria-hidden": "true",
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ _jsx("rect", {
|
|
42
|
+
width: "18",
|
|
43
|
+
height: "11",
|
|
44
|
+
x: "3",
|
|
45
|
+
y: "11",
|
|
46
|
+
rx: "2",
|
|
47
|
+
ry: "2"
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ _jsx("path", {
|
|
50
|
+
d: "M7 11V7a5 5 0 0 1 10 0v4"
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export function EyeIcon({ className }) {
|
|
56
|
+
return /*#__PURE__*/ _jsxs("svg", {
|
|
57
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
58
|
+
viewBox: "0 0 24 24",
|
|
59
|
+
fill: "none",
|
|
60
|
+
stroke: "currentColor",
|
|
61
|
+
strokeWidth: "2",
|
|
62
|
+
strokeLinecap: "round",
|
|
63
|
+
strokeLinejoin: "round",
|
|
64
|
+
className: cn("h-5 w-5", className),
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
children: [
|
|
67
|
+
/*#__PURE__*/ _jsx("path", {
|
|
68
|
+
d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"
|
|
69
|
+
}),
|
|
70
|
+
/*#__PURE__*/ _jsx("circle", {
|
|
71
|
+
cx: "12",
|
|
72
|
+
cy: "12",
|
|
73
|
+
r: "3"
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export function EyeOffIcon({ className }) {
|
|
79
|
+
return /*#__PURE__*/ _jsxs("svg", {
|
|
80
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
81
|
+
viewBox: "0 0 24 24",
|
|
82
|
+
fill: "none",
|
|
83
|
+
stroke: "currentColor",
|
|
84
|
+
strokeWidth: "2",
|
|
85
|
+
strokeLinecap: "round",
|
|
86
|
+
strokeLinejoin: "round",
|
|
87
|
+
className: cn("h-5 w-5", className),
|
|
88
|
+
"aria-hidden": "true",
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ _jsx("path", {
|
|
91
|
+
d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ _jsx("path", {
|
|
94
|
+
d: "M14.084 14.158a3 3 0 0 1-4.242-4.242"
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ _jsx("path", {
|
|
97
|
+
d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ _jsx("path", {
|
|
100
|
+
d: "m2 2 20 20"
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
export function HashIcon({ className }) {
|
|
106
|
+
return /*#__PURE__*/ _jsxs("svg", {
|
|
107
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
108
|
+
viewBox: "0 0 24 24",
|
|
109
|
+
fill: "none",
|
|
110
|
+
stroke: "currentColor",
|
|
111
|
+
strokeWidth: "2",
|
|
112
|
+
strokeLinecap: "round",
|
|
113
|
+
strokeLinejoin: "round",
|
|
114
|
+
className: cn("h-5 w-5", className),
|
|
115
|
+
"aria-hidden": "true",
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ _jsx("line", {
|
|
118
|
+
x1: "4",
|
|
119
|
+
x2: "20",
|
|
120
|
+
y1: "9",
|
|
121
|
+
y2: "9"
|
|
122
|
+
}),
|
|
123
|
+
/*#__PURE__*/ _jsx("line", {
|
|
124
|
+
x1: "4",
|
|
125
|
+
x2: "20",
|
|
126
|
+
y1: "15",
|
|
127
|
+
y2: "15"
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ _jsx("line", {
|
|
130
|
+
x1: "10",
|
|
131
|
+
x2: "8",
|
|
132
|
+
y1: "3",
|
|
133
|
+
y2: "21"
|
|
134
|
+
}),
|
|
135
|
+
/*#__PURE__*/ _jsx("line", {
|
|
136
|
+
x1: "16",
|
|
137
|
+
x2: "14",
|
|
138
|
+
y1: "3",
|
|
139
|
+
y2: "21"
|
|
140
|
+
})
|
|
141
|
+
]
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
export function PhoneIcon({ className }) {
|
|
145
|
+
return /*#__PURE__*/ _jsx("svg", {
|
|
146
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
147
|
+
viewBox: "0 0 24 24",
|
|
148
|
+
fill: "none",
|
|
149
|
+
stroke: "currentColor",
|
|
150
|
+
strokeWidth: "2",
|
|
151
|
+
strokeLinecap: "round",
|
|
152
|
+
strokeLinejoin: "round",
|
|
153
|
+
className: cn("h-5 w-5", className),
|
|
154
|
+
"aria-hidden": "true",
|
|
155
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
156
|
+
d: "M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
export function LinkIcon({ className }) {
|
|
161
|
+
return /*#__PURE__*/ _jsxs("svg", {
|
|
162
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
163
|
+
viewBox: "0 0 24 24",
|
|
164
|
+
fill: "none",
|
|
165
|
+
stroke: "currentColor",
|
|
166
|
+
strokeWidth: "2",
|
|
167
|
+
strokeLinecap: "round",
|
|
168
|
+
strokeLinejoin: "round",
|
|
169
|
+
className: cn("h-5 w-5", className),
|
|
170
|
+
"aria-hidden": "true",
|
|
171
|
+
children: [
|
|
172
|
+
/*#__PURE__*/ _jsx("path", {
|
|
173
|
+
d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"
|
|
174
|
+
}),
|
|
175
|
+
/*#__PURE__*/ _jsx("path", {
|
|
176
|
+
d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
export function TextIcon({ className }) {
|
|
182
|
+
return /*#__PURE__*/ _jsxs("svg", {
|
|
183
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
184
|
+
viewBox: "0 0 24 24",
|
|
185
|
+
fill: "none",
|
|
186
|
+
stroke: "currentColor",
|
|
187
|
+
strokeWidth: "2",
|
|
188
|
+
strokeLinecap: "round",
|
|
189
|
+
strokeLinejoin: "round",
|
|
190
|
+
className: cn("h-5 w-5", className),
|
|
191
|
+
"aria-hidden": "true",
|
|
192
|
+
children: [
|
|
193
|
+
/*#__PURE__*/ _jsx("polyline", {
|
|
194
|
+
points: "4 7 4 4 20 4 20 7"
|
|
195
|
+
}),
|
|
196
|
+
/*#__PURE__*/ _jsx("line", {
|
|
197
|
+
x1: "9",
|
|
198
|
+
x2: "15",
|
|
199
|
+
y1: "20",
|
|
200
|
+
y2: "20"
|
|
201
|
+
}),
|
|
202
|
+
/*#__PURE__*/ _jsx("line", {
|
|
203
|
+
x1: "12",
|
|
204
|
+
x2: "12",
|
|
205
|
+
y1: "4",
|
|
206
|
+
y2: "20"
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
export function CheckIcon({ className }) {
|
|
212
|
+
return /*#__PURE__*/ _jsx("svg", {
|
|
213
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
214
|
+
viewBox: "0 0 24 24",
|
|
215
|
+
fill: "none",
|
|
216
|
+
stroke: "currentColor",
|
|
217
|
+
strokeWidth: "2",
|
|
218
|
+
strokeLinecap: "round",
|
|
219
|
+
strokeLinejoin: "round",
|
|
220
|
+
className: cn("h-5 w-5", className),
|
|
221
|
+
"aria-hidden": "true",
|
|
222
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
223
|
+
d: "M20 6 9 17l-5-5"
|
|
224
|
+
})
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
export function AlertCircleIcon({ className }) {
|
|
228
|
+
return /*#__PURE__*/ _jsxs("svg", {
|
|
229
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
230
|
+
viewBox: "0 0 24 24",
|
|
231
|
+
fill: "none",
|
|
232
|
+
stroke: "currentColor",
|
|
233
|
+
strokeWidth: "2",
|
|
234
|
+
strokeLinecap: "round",
|
|
235
|
+
strokeLinejoin: "round",
|
|
236
|
+
className: cn("h-5 w-5", className),
|
|
237
|
+
"aria-hidden": "true",
|
|
238
|
+
children: [
|
|
239
|
+
/*#__PURE__*/ _jsx("circle", {
|
|
240
|
+
cx: "12",
|
|
241
|
+
cy: "12",
|
|
242
|
+
r: "10"
|
|
243
|
+
}),
|
|
244
|
+
/*#__PURE__*/ _jsx("line", {
|
|
245
|
+
x1: "12",
|
|
246
|
+
x2: "12",
|
|
247
|
+
y1: "8",
|
|
248
|
+
y2: "12"
|
|
249
|
+
}),
|
|
250
|
+
/*#__PURE__*/ _jsx("line", {
|
|
251
|
+
x1: "12",
|
|
252
|
+
x2: "12.01",
|
|
253
|
+
y1: "16",
|
|
254
|
+
y2: "16"
|
|
255
|
+
})
|
|
256
|
+
]
|
|
257
|
+
});
|
|
258
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useGSAP } from "@gsap/react";
|
|
4
|
+
import gsap from "gsap";
|
|
5
|
+
import { useId, useRef, useState } from "react";
|
|
6
|
+
import { nucleusTextInputTheme } from "../theme";
|
|
7
|
+
import { cn } from "../utils/cn";
|
|
8
|
+
import { formatNumberWithSeparator, formatPhoneNumber, unformatNumber, unformatPhone } from "../utils/format";
|
|
9
|
+
import { getAutoCompleteForType, getInputModeForType, validateWithConfig } from "../utils/validation";
|
|
10
|
+
import { FloatingLabel } from "./FloatingLabel";
|
|
11
|
+
import { AlertCircleIcon, CheckIcon, EyeIcon, EyeOffIcon, HashIcon, LinkIcon, LockIcon, MailIcon, PhoneIcon } from "./InputIcons";
|
|
12
|
+
import { PasswordStrengthIndicator } from "./PasswordStrengthIndicator";
|
|
13
|
+
import { TypewriterText } from "./TypewriterText";
|
|
14
|
+
gsap.registerPlugin(useGSAP);
|
|
15
|
+
const TYPE_ICONS = {
|
|
16
|
+
text: null,
|
|
17
|
+
email: /*#__PURE__*/ _jsx(MailIcon, {}),
|
|
18
|
+
password: /*#__PURE__*/ _jsx(LockIcon, {}),
|
|
19
|
+
number: /*#__PURE__*/ _jsx(HashIcon, {}),
|
|
20
|
+
tel: /*#__PURE__*/ _jsx(PhoneIcon, {}),
|
|
21
|
+
url: /*#__PURE__*/ _jsx(LinkIcon, {})
|
|
22
|
+
};
|
|
23
|
+
export function NucleusTextInput({ value = "", onChange, type = "text", label, placeholder, helperText, errorMessage, disabled = false, readOnly = false, leftIcon, rightIcon, size = "md", fullWidth = true, className, inputClassName, labelClassName, wrapperClassName, showTypewriterError = true, showTypeIcon = true, showValidationIcon = true, enableValidation = true, validateOnBlur = true, validateOnChange = false, validationConfig, customValidator, onValidationChange, unit, unitPosition = "suffix", formatNumber = false, thousandSeparator = " ", phoneFormat = "tr", isNewPassword = false, maxInputLength, confirmValue, onConfirmChange, showPasswordStrength = false, preventCopy = false, preventPaste = false, preventContextMenu = false, trimOnBlur = false, onFocus, onBlur, ...restProps }) {
|
|
24
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
25
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
26
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
27
|
+
const [internalError, setInternalError] = useState(undefined);
|
|
28
|
+
const [isValid, setIsValid] = useState(null);
|
|
29
|
+
const inputRef = useRef(null);
|
|
30
|
+
const wrapperRef = useRef(null);
|
|
31
|
+
const inputId = useId();
|
|
32
|
+
const theme = nucleusTextInputTheme;
|
|
33
|
+
const displayError = errorMessage || internalError;
|
|
34
|
+
const hasError = Boolean(displayError);
|
|
35
|
+
const hasValue = Boolean(value && value.length > 0);
|
|
36
|
+
const isFloated = isFocused || hasValue;
|
|
37
|
+
const { contextSafe } = useGSAP({
|
|
38
|
+
scope: wrapperRef
|
|
39
|
+
});
|
|
40
|
+
const runValidation = (val)=>{
|
|
41
|
+
if (!enableValidation) return {
|
|
42
|
+
isValid: true
|
|
43
|
+
};
|
|
44
|
+
if (customValidator) {
|
|
45
|
+
return customValidator(val);
|
|
46
|
+
}
|
|
47
|
+
return validateWithConfig(val, type, validationConfig);
|
|
48
|
+
};
|
|
49
|
+
const handleValidation = (val)=>{
|
|
50
|
+
const result = runValidation(val);
|
|
51
|
+
setIsValid(result.isValid);
|
|
52
|
+
setInternalError(result.isValid ? undefined : result.errorMessage);
|
|
53
|
+
onValidationChange?.(result);
|
|
54
|
+
};
|
|
55
|
+
const handleFocus = contextSafe((e)=>{
|
|
56
|
+
if (disabled) return;
|
|
57
|
+
setIsFocused(true);
|
|
58
|
+
onFocus?.(e);
|
|
59
|
+
});
|
|
60
|
+
const handleBlur = contextSafe((e)=>{
|
|
61
|
+
setIsFocused(false);
|
|
62
|
+
if (trimOnBlur && value) {
|
|
63
|
+
const trimmed = value.trim();
|
|
64
|
+
if (trimmed !== value) {
|
|
65
|
+
onChange?.(trimmed);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (validateOnBlur && value) {
|
|
69
|
+
handleValidation(getUnformattedValue(value));
|
|
70
|
+
}
|
|
71
|
+
if (type === "password" && confirmValue !== undefined && value !== confirmValue) {
|
|
72
|
+
setInternalError("Passwords do not match");
|
|
73
|
+
setIsValid(false);
|
|
74
|
+
}
|
|
75
|
+
onBlur?.(e);
|
|
76
|
+
});
|
|
77
|
+
const handleCopy = (e)=>{
|
|
78
|
+
if (preventCopy || type === "password") {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const handlePaste = (e)=>{
|
|
83
|
+
if (preventPaste) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const handleContextMenu = (e)=>{
|
|
88
|
+
if (preventContextMenu || type === "password") {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const handleChange = (e)=>{
|
|
93
|
+
const input = e.target;
|
|
94
|
+
const cursorPos = input.selectionStart ?? 0;
|
|
95
|
+
const oldValue = value;
|
|
96
|
+
let newValue = e.target.value;
|
|
97
|
+
const oldRawLength = unformatNumber(oldValue).length;
|
|
98
|
+
const newRawLength = unformatNumber(newValue).length;
|
|
99
|
+
const isDeleting = newRawLength < oldRawLength;
|
|
100
|
+
if (type === "number" && formatNumber) {
|
|
101
|
+
const rawValue = unformatNumber(newValue);
|
|
102
|
+
newValue = formatNumberWithSeparator(rawValue, thousandSeparator);
|
|
103
|
+
} else if (type === "tel") {
|
|
104
|
+
newValue = formatPhoneNumber(newValue, phoneFormat);
|
|
105
|
+
}
|
|
106
|
+
onChange?.(newValue);
|
|
107
|
+
if (type === "number" && formatNumber || type === "tel") {
|
|
108
|
+
requestAnimationFrame(()=>{
|
|
109
|
+
if (!inputRef.current) return;
|
|
110
|
+
const rawBeforeCursor = unformatNumber(e.target.value.slice(0, cursorPos)).length;
|
|
111
|
+
let newCursorPos = 0;
|
|
112
|
+
let rawCount = 0;
|
|
113
|
+
for(let i = 0; i < newValue.length; i++){
|
|
114
|
+
const char = newValue[i];
|
|
115
|
+
if (char !== undefined && /\d/.test(char)) {
|
|
116
|
+
rawCount++;
|
|
117
|
+
}
|
|
118
|
+
if (rawCount === rawBeforeCursor) {
|
|
119
|
+
newCursorPos = i + 1;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (rawCount < rawBeforeCursor) {
|
|
124
|
+
newCursorPos = newValue.length;
|
|
125
|
+
}
|
|
126
|
+
if (isDeleting && cursorPos > 0) {
|
|
127
|
+
const charBeforeCursor = e.target.value[cursorPos - 1];
|
|
128
|
+
if (charBeforeCursor === " " || charBeforeCursor === thousandSeparator) {
|
|
129
|
+
newCursorPos = Math.max(0, newCursorPos - 1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
inputRef.current.setSelectionRange(newCursorPos, newCursorPos);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (validateOnChange) {
|
|
136
|
+
const validationValue = getUnformattedValue(newValue);
|
|
137
|
+
handleValidation(validationValue);
|
|
138
|
+
}
|
|
139
|
+
if (type === "password" && confirmValue !== undefined && newValue !== confirmValue) {
|
|
140
|
+
setInternalError("Passwords do not match");
|
|
141
|
+
setIsValid(false);
|
|
142
|
+
} else if (type === "password" && confirmValue !== undefined && newValue === confirmValue) {
|
|
143
|
+
setInternalError(undefined);
|
|
144
|
+
setIsValid(true);
|
|
145
|
+
} else if (internalError && !validateOnChange) {
|
|
146
|
+
setInternalError(undefined);
|
|
147
|
+
setIsValid(null);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const getUnformattedValue = (val)=>{
|
|
151
|
+
if (type === "number" && formatNumber) return unformatNumber(val);
|
|
152
|
+
if (type === "tel") return unformatPhone(val);
|
|
153
|
+
return val;
|
|
154
|
+
};
|
|
155
|
+
const getDisplayValue = ()=>{
|
|
156
|
+
if (type === "number" && formatNumber && value) {
|
|
157
|
+
return formatNumberWithSeparator(unformatNumber(value), thousandSeparator);
|
|
158
|
+
}
|
|
159
|
+
if (type === "tel" && value) {
|
|
160
|
+
return formatPhoneNumber(value, phoneFormat);
|
|
161
|
+
}
|
|
162
|
+
return value;
|
|
163
|
+
};
|
|
164
|
+
const togglePasswordVisibility = ()=>{
|
|
165
|
+
setShowPassword((prev)=>!prev);
|
|
166
|
+
};
|
|
167
|
+
const getInputType = ()=>{
|
|
168
|
+
if (type === "password") {
|
|
169
|
+
return showPassword ? "text" : "password";
|
|
170
|
+
}
|
|
171
|
+
return type;
|
|
172
|
+
};
|
|
173
|
+
const getTypeIcon = ()=>{
|
|
174
|
+
if (!showTypeIcon) return null;
|
|
175
|
+
if (leftIcon) return null;
|
|
176
|
+
if (type === "number" && unit) return null;
|
|
177
|
+
return TYPE_ICONS[type];
|
|
178
|
+
};
|
|
179
|
+
const getValidationIcon = ()=>{
|
|
180
|
+
if (!showValidationIcon || !hasValue || isValid === null) return null;
|
|
181
|
+
if (hasError) return /*#__PURE__*/ _jsx(AlertCircleIcon, {
|
|
182
|
+
className: "text-red-500"
|
|
183
|
+
});
|
|
184
|
+
if (isValid) return /*#__PURE__*/ _jsx(CheckIcon, {
|
|
185
|
+
className: "text-green-500"
|
|
186
|
+
});
|
|
187
|
+
return null;
|
|
188
|
+
};
|
|
189
|
+
const getRightIcon = ()=>{
|
|
190
|
+
if (type === "password") {
|
|
191
|
+
return /*#__PURE__*/ _jsx("button", {
|
|
192
|
+
type: "button",
|
|
193
|
+
onClick: togglePasswordVisibility,
|
|
194
|
+
className: "focus:outline-none",
|
|
195
|
+
tabIndex: -1,
|
|
196
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
197
|
+
children: showPassword ? /*#__PURE__*/ _jsx(EyeOffIcon, {}) : /*#__PURE__*/ _jsx(EyeIcon, {})
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (rightIcon) return rightIcon;
|
|
201
|
+
return getValidationIcon();
|
|
202
|
+
};
|
|
203
|
+
const handleMouseEnter = contextSafe(()=>{
|
|
204
|
+
if (disabled) return;
|
|
205
|
+
setIsHovered(true);
|
|
206
|
+
if (wrapperRef.current && !isFocused && !hasError) {
|
|
207
|
+
gsap.to(wrapperRef.current, {
|
|
208
|
+
borderColor: "rgb(156, 163, 175)",
|
|
209
|
+
duration: theme.animation.border.duration,
|
|
210
|
+
ease: theme.animation.border.ease
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
const handleMouseLeave = contextSafe(()=>{
|
|
215
|
+
setIsHovered(false);
|
|
216
|
+
if (wrapperRef.current && !isFocused && !hasError) {
|
|
217
|
+
gsap.to(wrapperRef.current, {
|
|
218
|
+
borderColor: "rgb(209, 213, 219)",
|
|
219
|
+
duration: theme.animation.border.duration,
|
|
220
|
+
ease: theme.animation.border.ease
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
const getBorderStateClass = ()=>{
|
|
225
|
+
if (disabled) return theme.wrapper.states.disabled;
|
|
226
|
+
if (hasError) return theme.wrapper.states.error;
|
|
227
|
+
if (isFocused) return theme.wrapper.states.focused;
|
|
228
|
+
if (isHovered) return theme.wrapper.states.hover;
|
|
229
|
+
return theme.wrapper.states.inactive;
|
|
230
|
+
};
|
|
231
|
+
const getSizeClasses = ()=>{
|
|
232
|
+
switch(size){
|
|
233
|
+
case "sm":
|
|
234
|
+
return "px-3 py-2 text-sm";
|
|
235
|
+
case "lg":
|
|
236
|
+
return "px-5 py-4 text-lg";
|
|
237
|
+
default:
|
|
238
|
+
return theme.wrapper.padding;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
242
|
+
className: cn(theme.container.base, theme.container.spacing, fullWidth && "w-full", className),
|
|
243
|
+
children: [
|
|
244
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
245
|
+
ref: wrapperRef,
|
|
246
|
+
htmlFor: inputId,
|
|
247
|
+
className: cn(theme.wrapper.base, theme.wrapper.border.base, theme.wrapper.transition, getSizeClasses(), getBorderStateClass(), "cursor-text", wrapperClassName),
|
|
248
|
+
onMouseEnter: handleMouseEnter,
|
|
249
|
+
onMouseLeave: handleMouseLeave,
|
|
250
|
+
children: [
|
|
251
|
+
(leftIcon || getTypeIcon()) && /*#__PURE__*/ _jsx("span", {
|
|
252
|
+
className: cn(theme.icon.base, theme.icon.size, theme.icon.color, theme.icon.spacing.left, isFocused && theme.icon.states.focused, hasError && theme.icon.states.error, disabled && theme.icon.states.disabled),
|
|
253
|
+
children: leftIcon || getTypeIcon()
|
|
254
|
+
}),
|
|
255
|
+
label && /*#__PURE__*/ _jsx(FloatingLabel, {
|
|
256
|
+
label: label,
|
|
257
|
+
isFloated: isFloated,
|
|
258
|
+
isFocused: isFocused,
|
|
259
|
+
hasError: hasError,
|
|
260
|
+
isDisabled: disabled,
|
|
261
|
+
hasLeftIcon: Boolean(leftIcon || getTypeIcon()),
|
|
262
|
+
className: labelClassName
|
|
263
|
+
}),
|
|
264
|
+
unit && unitPosition === "prefix" && /*#__PURE__*/ _jsx("span", {
|
|
265
|
+
className: "text-gray-500 dark:text-gray-400 mr-1 select-none",
|
|
266
|
+
children: unit
|
|
267
|
+
}),
|
|
268
|
+
/*#__PURE__*/ _jsx("input", {
|
|
269
|
+
ref: inputRef,
|
|
270
|
+
id: inputId,
|
|
271
|
+
type: type === "number" && formatNumber ? "text" : getInputType(),
|
|
272
|
+
inputMode: getInputModeForType(type),
|
|
273
|
+
autoComplete: getAutoCompleteForType(type, isNewPassword),
|
|
274
|
+
maxLength: maxInputLength,
|
|
275
|
+
value: getDisplayValue(),
|
|
276
|
+
onChange: handleChange,
|
|
277
|
+
onFocus: handleFocus,
|
|
278
|
+
onBlur: handleBlur,
|
|
279
|
+
onCopy: handleCopy,
|
|
280
|
+
onPaste: handlePaste,
|
|
281
|
+
onContextMenu: handleContextMenu,
|
|
282
|
+
disabled: disabled,
|
|
283
|
+
readOnly: readOnly,
|
|
284
|
+
placeholder: isFloated ? placeholder : "",
|
|
285
|
+
"aria-label": label,
|
|
286
|
+
"aria-invalid": hasError,
|
|
287
|
+
"aria-describedby": displayError ? `${inputId}-error` : helperText ? `${inputId}-helper` : undefined,
|
|
288
|
+
className: cn(theme.input.base, theme.input.text, theme.input.color, theme.input.placeholder, theme.input.transition, disabled && theme.input.disabled, inputClassName),
|
|
289
|
+
...restProps
|
|
290
|
+
}),
|
|
291
|
+
unit && unitPosition === "suffix" && /*#__PURE__*/ _jsx("span", {
|
|
292
|
+
className: "text-gray-500 dark:text-gray-400 ml-1 select-none",
|
|
293
|
+
children: unit
|
|
294
|
+
}),
|
|
295
|
+
getRightIcon() && /*#__PURE__*/ _jsx("span", {
|
|
296
|
+
className: cn(theme.icon.base, theme.icon.size, theme.icon.color, theme.icon.spacing.right, isFocused && theme.icon.states.focused, hasError && theme.icon.states.error, disabled && theme.icon.states.disabled),
|
|
297
|
+
children: getRightIcon()
|
|
298
|
+
})
|
|
299
|
+
]
|
|
300
|
+
}),
|
|
301
|
+
/*#__PURE__*/ _jsx("div", {
|
|
302
|
+
className: theme.errorText.minHeight,
|
|
303
|
+
children: hasError && showTypewriterError && displayError ? /*#__PURE__*/ _jsx(TypewriterText, {
|
|
304
|
+
text: displayError
|
|
305
|
+
}) : hasError ? /*#__PURE__*/ _jsx("span", {
|
|
306
|
+
id: `${inputId}-error`,
|
|
307
|
+
className: cn(theme.errorText.base, theme.errorText.text, theme.errorText.color),
|
|
308
|
+
role: "alert",
|
|
309
|
+
children: displayError
|
|
310
|
+
}) : helperText ? /*#__PURE__*/ _jsx("span", {
|
|
311
|
+
id: `${inputId}-helper`,
|
|
312
|
+
className: cn(theme.helperText.base, theme.helperText.text, theme.helperText.color, disabled && theme.helperText.disabled),
|
|
313
|
+
children: helperText
|
|
314
|
+
}) : null
|
|
315
|
+
}),
|
|
316
|
+
type === "password" && showPasswordStrength && value && /*#__PURE__*/ _jsx(PasswordStrengthIndicator, {
|
|
317
|
+
password: value
|
|
318
|
+
})
|
|
319
|
+
]
|
|
320
|
+
});
|
|
321
|
+
}
|