Update Fix
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
import type React from "react";
|
||||
|
||||
interface CheckboxProps {
|
||||
label?: string;
|
||||
checked: boolean;
|
||||
className?: string;
|
||||
id?: string;
|
||||
onChange: (checked: boolean) => void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
const Checkbox: React.FC<CheckboxProps> = ({
|
||||
label,
|
||||
checked,
|
||||
id,
|
||||
onChange,
|
||||
className = "",
|
||||
disabled = false,
|
||||
}) => {
|
||||
return (
|
||||
<label
|
||||
className={`flex items-center space-x-3 group cursor-pointer ${
|
||||
disabled ? "cursor-not-allowed opacity-60" : ""
|
||||
}`}
|
||||
>
|
||||
<div className="relative w-5 h-5">
|
||||
<input
|
||||
id={id}
|
||||
type="checkbox"
|
||||
className={`w-5 h-5 appearance-none cursor-pointer dark:border-gray-700 border border-gray-300 checked:border-transparent rounded-md checked:bg-brand-500 disabled:opacity-60
|
||||
${className}`}
|
||||
checked={checked}
|
||||
onChange={(e) => onChange(e.target.checked)}
|
||||
disabled={disabled}
|
||||
/>
|
||||
{checked && (
|
||||
<svg
|
||||
className="absolute transform -translate-x-1/2 -translate-y-1/2 pointer-events-none top-1/2 left-1/2"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="14"
|
||||
height="14"
|
||||
viewBox="0 0 14 14"
|
||||
fill="none"
|
||||
>
|
||||
<path
|
||||
d="M11.6666 3.5L5.24992 9.91667L2.33325 7"
|
||||
stroke="white"
|
||||
strokeWidth="1.94437"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
)}
|
||||
{disabled && (
|
||||
<svg
|
||||
className="absolute transform -translate-x-1/2 -translate-y-1/2 pointer-events-none top-1/2 left-1/2"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="14"
|
||||
height="14"
|
||||
viewBox="0 0 14 14"
|
||||
fill="none"
|
||||
>
|
||||
<path
|
||||
d="M11.6666 3.5L5.24992 9.91667L2.33325 7"
|
||||
stroke="#E4E7EC"
|
||||
strokeWidth="2.33333"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
)}
|
||||
</div>
|
||||
{label && (
|
||||
<span className="text-sm font-medium text-gray-800 dark:text-gray-200">
|
||||
{label}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
);
|
||||
};
|
||||
|
||||
export default Checkbox;
|
||||
@@ -0,0 +1,18 @@
|
||||
import { FC } from "react";
|
||||
|
||||
interface FileInputProps {
|
||||
className?: string;
|
||||
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
}
|
||||
|
||||
const FileInput: FC<FileInputProps> = ({ className, onChange }) => {
|
||||
return (
|
||||
<input
|
||||
type="file"
|
||||
className={`focus:border-ring-brand-300 h-11 w-full overflow-hidden rounded-lg border border-gray-300 bg-transparent text-sm text-gray-500 shadow-theme-xs transition-colors file:mr-5 file:border-collapse file:cursor-pointer file:rounded-l-lg file:border-0 file:border-r file:border-solid file:border-gray-200 file:bg-gray-50 file:py-3 file:pl-3.5 file:pr-3 file:text-sm file:text-gray-700 placeholder:text-gray-400 hover:file:bg-gray-100 focus:outline-hidden focus:file:ring-brand-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-400 dark:text-white/90 dark:file:border-gray-800 dark:file:bg-white/[0.03] dark:file:text-gray-400 dark:placeholder:text-gray-400 ${className}`}
|
||||
onChange={onChange}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default FileInput;
|
||||
@@ -0,0 +1,82 @@
|
||||
import type React from "react";
|
||||
import type { FC } from "react";
|
||||
|
||||
interface InputProps {
|
||||
type?: "text" | "number" | "email" | "password" | "date" | "time" | string;
|
||||
id?: string;
|
||||
name?: string;
|
||||
placeholder?: string;
|
||||
value?: string | number;
|
||||
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
className?: string;
|
||||
min?: string;
|
||||
max?: string;
|
||||
step?: number;
|
||||
disabled?: boolean;
|
||||
success?: boolean;
|
||||
error?: boolean;
|
||||
hint?: string;
|
||||
}
|
||||
|
||||
const Input: FC<InputProps> = ({
|
||||
type = "text",
|
||||
id,
|
||||
name,
|
||||
placeholder,
|
||||
value,
|
||||
onChange,
|
||||
className = "",
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
disabled = false,
|
||||
success = false,
|
||||
error = false,
|
||||
hint,
|
||||
}) => {
|
||||
let inputClasses = ` h-11 w-full rounded-lg border appearance-none px-4 py-2.5 text-sm shadow-theme-xs placeholder:text-gray-400 focus:outline-hidden focus:ring-3 dark:bg-gray-900 dark:text-white/90 dark:placeholder:text-white/30 ${className}`;
|
||||
|
||||
if (disabled) {
|
||||
inputClasses += ` text-gray-500 border-gray-300 opacity-40 bg-gray-100 cursor-not-allowed dark:bg-gray-800 dark:text-gray-400 dark:border-gray-700 opacity-40`;
|
||||
} else if (error) {
|
||||
inputClasses += ` border-error-500 focus:border-error-300 focus:ring-error-500/20 dark:text-error-400 dark:border-error-500 dark:focus:border-error-800`;
|
||||
} else if (success) {
|
||||
inputClasses += ` border-success-500 focus:border-success-300 focus:ring-success-500/20 dark:text-success-400 dark:border-success-500 dark:focus:border-success-800`;
|
||||
} else {
|
||||
inputClasses += ` bg-transparent text-gray-800 border-gray-300 focus:border-brand-300 focus:ring-brand-500/20 dark:border-gray-700 dark:text-white/90 dark:focus:border-brand-800`;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<input
|
||||
type={type}
|
||||
id={id}
|
||||
name={name}
|
||||
placeholder={placeholder}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
disabled={disabled}
|
||||
className={inputClasses}
|
||||
/>
|
||||
|
||||
{hint && (
|
||||
<p
|
||||
className={`mt-1.5 text-xs ${
|
||||
error
|
||||
? "text-error-500"
|
||||
: success
|
||||
? "text-success-500"
|
||||
: "text-gray-500"
|
||||
}`}
|
||||
>
|
||||
{hint}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Input;
|
||||
63
resources/js/admin/tailadmin/components/form/input/Radio.tsx
Normal file
63
resources/js/admin/tailadmin/components/form/input/Radio.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
interface RadioProps {
|
||||
id: string; // Unique ID for the radio button
|
||||
name: string; // Radio group name
|
||||
value: string; // Value of the radio button
|
||||
checked: boolean; // Whether the radio button is checked
|
||||
label: string; // Label for the radio button
|
||||
onChange: (value: string) => void; // Handler for value change
|
||||
className?: string; // Optional additional classes
|
||||
disabled?: boolean; // Optional disabled state for the radio button
|
||||
}
|
||||
|
||||
const Radio: React.FC<RadioProps> = ({
|
||||
id,
|
||||
name,
|
||||
value,
|
||||
checked,
|
||||
label,
|
||||
onChange,
|
||||
className = "",
|
||||
disabled = false,
|
||||
}) => {
|
||||
return (
|
||||
<label
|
||||
htmlFor={id}
|
||||
className={`relative flex cursor-pointer select-none items-center gap-3 text-sm font-medium ${
|
||||
disabled
|
||||
? "text-gray-300 dark:text-gray-600 cursor-not-allowed"
|
||||
: "text-gray-700 dark:text-gray-400"
|
||||
} ${className}`}
|
||||
>
|
||||
<input
|
||||
id={id}
|
||||
name={name}
|
||||
type="radio"
|
||||
value={value}
|
||||
checked={checked}
|
||||
onChange={() => !disabled && onChange(value)} // Prevent onChange when disabled
|
||||
className="sr-only"
|
||||
disabled={disabled} // Disable input
|
||||
/>
|
||||
<span
|
||||
className={`flex h-5 w-5 items-center justify-center rounded-full border-[1.25px] ${
|
||||
checked
|
||||
? "border-brand-500 bg-brand-500"
|
||||
: "bg-transparent border-gray-300 dark:border-gray-700"
|
||||
} ${
|
||||
disabled
|
||||
? "bg-gray-100 dark:bg-gray-700 border-gray-200 dark:border-gray-700"
|
||||
: ""
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`h-2 w-2 rounded-full bg-white ${
|
||||
checked ? "block" : "hidden"
|
||||
}`}
|
||||
></span>
|
||||
</span>
|
||||
{label}
|
||||
</label>
|
||||
);
|
||||
};
|
||||
|
||||
export default Radio;
|
||||
@@ -0,0 +1,57 @@
|
||||
interface RadioProps {
|
||||
id: string; // Unique ID for the radio button
|
||||
name: string; // Group name for the radio button
|
||||
value: string; // Value of the radio button
|
||||
checked: boolean; // Whether the radio button is checked
|
||||
label: string; // Label text for the radio button
|
||||
onChange: (value: string) => void; // Handler for when the radio button is toggled
|
||||
className?: string; // Optional custom classes for styling
|
||||
}
|
||||
|
||||
const RadioSm: React.FC<RadioProps> = ({
|
||||
id,
|
||||
name,
|
||||
value,
|
||||
checked,
|
||||
label,
|
||||
onChange,
|
||||
className = "",
|
||||
}) => {
|
||||
return (
|
||||
<label
|
||||
htmlFor={id}
|
||||
className={`flex cursor-pointer select-none items-center text-sm text-gray-500 dark:text-gray-400 ${className}`}
|
||||
>
|
||||
<span className="relative">
|
||||
{/* Hidden Input */}
|
||||
<input
|
||||
type="radio"
|
||||
id={id}
|
||||
name={name}
|
||||
value={value}
|
||||
checked={checked}
|
||||
onChange={() => onChange(value)}
|
||||
className="sr-only"
|
||||
/>
|
||||
{/* Styled Radio Circle */}
|
||||
<span
|
||||
className={`mr-2 flex h-4 w-4 items-center justify-center rounded-full border ${
|
||||
checked
|
||||
? "border-brand-500 bg-brand-500"
|
||||
: "bg-transparent border-gray-300 dark:border-gray-700"
|
||||
}`}
|
||||
>
|
||||
{/* Inner Dot */}
|
||||
<span
|
||||
className={`h-1.5 w-1.5 rounded-full ${
|
||||
checked ? "bg-white" : "bg-white dark:bg-[#1e2636]"
|
||||
}`}
|
||||
></span>
|
||||
</span>
|
||||
</span>
|
||||
{label}
|
||||
</label>
|
||||
);
|
||||
};
|
||||
|
||||
export default RadioSm;
|
||||
@@ -0,0 +1,63 @@
|
||||
import React from "react";
|
||||
|
||||
interface TextareaProps {
|
||||
placeholder?: string; // Placeholder text
|
||||
rows?: number; // Number of rows
|
||||
value?: string; // Current value
|
||||
onChange?: (value: string) => void; // Change handler
|
||||
className?: string; // Additional CSS classes
|
||||
disabled?: boolean; // Disabled state
|
||||
error?: boolean; // Error state
|
||||
hint?: string; // Hint text to display
|
||||
}
|
||||
|
||||
const TextArea: React.FC<TextareaProps> = ({
|
||||
placeholder = "Enter your message", // Default placeholder
|
||||
rows = 3, // Default number of rows
|
||||
value = "", // Default value
|
||||
onChange, // Callback for changes
|
||||
className = "", // Additional custom styles
|
||||
disabled = false, // Disabled state
|
||||
error = false, // Error state
|
||||
hint = "", // Default hint text
|
||||
}) => {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||
if (onChange) {
|
||||
onChange(e.target.value);
|
||||
}
|
||||
};
|
||||
|
||||
let textareaClasses = `w-full rounded-lg border px-4 py-2.5 text-sm shadow-theme-xs focus:outline-hidden ${className} `;
|
||||
|
||||
if (disabled) {
|
||||
textareaClasses += ` bg-gray-100 opacity-50 text-gray-500 border-gray-300 cursor-not-allowed opacity40 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-700`;
|
||||
} else if (error) {
|
||||
textareaClasses += ` bg-transparent border-gray-300 focus:border-error-300 focus:ring-3 focus:ring-error-500/10 dark:border-gray-700 dark:bg-gray-900 dark:text-white/90 dark:focus:border-error-800`;
|
||||
} else {
|
||||
textareaClasses += ` bg-transparent text-gray-900 dark:text-gray-300 text-gray-900 border-gray-300 focus:border-brand-300 focus:ring-3 focus:ring-brand-500/10 dark:border-gray-700 dark:bg-gray-900 dark:text-white/90 dark:focus:border-brand-800`;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<textarea
|
||||
placeholder={placeholder}
|
||||
rows={rows}
|
||||
value={value}
|
||||
onChange={handleChange}
|
||||
disabled={disabled}
|
||||
className={textareaClasses}
|
||||
/>
|
||||
{hint && (
|
||||
<p
|
||||
className={`mt-2 text-sm ${
|
||||
error ? "text-error-500" : "text-gray-500 dark:text-gray-400"
|
||||
}`}
|
||||
>
|
||||
{hint}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TextArea;
|
||||
Reference in New Issue
Block a user