mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-02 13:15:17 +09:00
- New useOverflowItems hook for tab overflow menus - Refactor ui/tabs and ds/PageTopbar to share overflow logic - New PageLoader component for full-page loading states - New DataTable component with sorting, empty/loading states, custom rows - New ResourceCard / ResourceList for servers/apps/domains/containers - New FormField / FormRow wrappers for consistent forms - New IconButton wrapper for accessible icon-only actions - Add supporting styles in _design-system.scss and _forms.scss
58 lines
1.5 KiB
React
58 lines
1.5 KiB
React
import React from 'react';
|
|
import { Label } from '@/components/ui/label';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
/**
|
|
* Standard form field wrapper: label, hint, error message, and input slot.
|
|
*
|
|
* <FormField label="Email" htmlFor="email" error="Required" hint="Used for notifications">
|
|
* <Input id="email" ... />
|
|
* </FormField>
|
|
*/
|
|
export function FormField({
|
|
label,
|
|
htmlFor,
|
|
children,
|
|
error,
|
|
hint,
|
|
required = false,
|
|
className,
|
|
labelClassName,
|
|
}) {
|
|
const inputId = htmlFor;
|
|
|
|
return (
|
|
<div className={cn('form-field', className)}>
|
|
{label && (
|
|
<Label htmlFor={inputId} className={cn('form-field__label', labelClassName)}>
|
|
{label}
|
|
{required && <span className="form-field__required" aria-hidden="true">*</span>}
|
|
</Label>
|
|
)}
|
|
<div className="form-field__control">
|
|
{children}
|
|
</div>
|
|
{hint && !error && <p className="form-field__hint">{hint}</p>}
|
|
{error && <p className="form-field__error" role="alert">{error}</p>}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Horizontal row of form fields. Use for side-by-side inputs.
|
|
*
|
|
* <FormRow>
|
|
* <FormField label="First name"><Input ... /></FormField>
|
|
* <FormField label="Last name"><Input ... /></FormField>
|
|
* </FormRow>
|
|
*/
|
|
export function FormRow({ children, className }) {
|
|
return (
|
|
<div className={cn('form-row', className)}>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default FormField;
|