{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "field",
  "type": "registry:ui",
  "title": "Field",
  "description": "قالب مشترک برچسب + کنترل + راهنما/خطا",
  "registryDependencies": [
    "https://kashi.sepantapouya.com/r/cx.json",
    "https://kashi.sepantapouya.com/r/kashi-provider.json"
  ],
  "files": [
    {
      "path": "registry/kashi/Field.tsx",
      "type": "registry:ui",
      "target": "components/kashi/Field.tsx",
      "content": "\"use client\";\n\nimport { type ReactNode } from \"react\";\nimport { cx } from \"./cx\";\nimport { useKashi } from \"./KashiProvider\";\n\n/** کلاس دلخواه برای هر بخش داخلی فیلد */\nexport interface FieldClassNames {\n  root?: string;\n  label?: string;\n  hint?: string;\n  error?: string;\n}\n\nexport interface FieldProps {\n  id: string;\n  label?: ReactNode;\n  hint?: ReactNode;\n  error?: ReactNode;\n  required?: boolean;\n  /** نشان «اختیاری» کنار برچسب */\n  optional?: boolean | string;\n  /** محتوای انتهای ردیف برچسب، مثل شمارندهٔ نویسه یا لینک «فراموشی رمز» */\n  labelEnd?: ReactNode;\n  /** محتوای انتهای ردیف راهنما، مثل شمارنده */\n  hintEnd?: ReactNode;\n  className?: string;\n  classNames?: FieldClassNames;\n  children: ReactNode;\n}\n\n/** شناسهٔ متن‌های راهنما و خطا برای aria-describedby */\nexport const hintId = (id: string) => `${id}-hint`;\nexport const errorId = (id: string) => `${id}-error`;\n\nexport function describedBy(id: string, hint: unknown, error: unknown, extra?: string): string | undefined {\n  return [extra, error ? errorId(id) : null, hint ? hintId(id) : null].filter(Boolean).join(\" \") || undefined;\n}\n\n/** قالب مشترک برچسب + کنترل + راهنما/خطا */\nexport function Field({ id, label, hint, error, required, optional, labelEnd, hintEnd, className, classNames = {}, children }: FieldProps) {\n  const { messages: M } = useKashi();\n  const optionalText = optional === true ? M.common.optional : optional;\n  return (\n    <div className={cx(\"k-field\", className, classNames.root)} data-invalid={error ? \"\" : undefined}>\n      {(label || labelEnd) && (\n        <div className=\"k-field__label-row\">\n          {label && (\n            <label className={cx(\"k-label\", classNames.label)} htmlFor={id}>\n              {label}\n              {required && <span className=\"k-label__required\" aria-hidden=\"true\">*</span>}\n              {optionalText && <span className=\"k-label__optional\">{optionalText}</span>}\n            </label>\n          )}\n          {labelEnd && <span className=\"k-field__label-end\">{labelEnd}</span>}\n        </div>\n      )}\n      {children}\n      {(error || hint || hintEnd) && (\n        <div className=\"k-field__hint-row\">\n          <div className=\"k-field__hints\">\n            {error && <p className={cx(\"k-hint k-hint--error\", classNames.error)} id={errorId(id)}>{error}</p>}\n            {hint && <p className={cx(\"k-hint\", classNames.hint)} id={hintId(id)}>{hint}</p>}\n          </div>\n          {hintEnd}\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}