{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "author": "Lopifi (https://lopifi.com)",
  "categories": [
    "accounting-core-gl",
    "finance",
    "accounting"
  ],
  "dependencies": [],
  "description": "Entity always required; renders what the account demands.",
  "files": [
    {
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport type { DimensionKey } from \"@/lib/ledger/accounting.types\";\nimport { cn } from \"@/lib/ledger/cn\";\n\nconst LABELS: Record<DimensionKey, string> = {\n  classId: \"Class\",\n  customerId: \"Customer\",\n  departmentId: \"Department\",\n  entityId: \"Entity\",\n  locationId: \"Location\",\n  productId: \"Product\",\n  projectId: \"Project\",\n  vendorId: \"Vendor\",\n};\n\nconst OPTIONS: Record<DimensionKey, string[]> = {\n  classId: [\"Core\", \"New product\"],\n  customerId: [\"Contoso\", \"Fabrikam\", \"Tailspin\"],\n  departmentId: [\"G&A\", \"Engineering\", \"Sales\", \"Marketing\"],\n  entityId: [\"Northwind Ltd\", \"Northwind GmbH\", \"Northwind Inc\"],\n  locationId: [\"London\", \"Berlin\", \"New York\"],\n  productId: [\"Platform\", \"Services\"],\n  projectId: [\"Atlas\", \"Beacon\"],\n  vendorId: [\"Baker & Co\", \"Vertex Cloud\", \"Meridian Legal\"],\n};\n\nexport interface DimensionPickerProps {\n  className?: string;\n  onValueChange: (value: Partial<Record<DimensionKey, string>>) => void;\n  /** Rendered from what the chosen account demands, not a global list. */\n  required: DimensionKey[];\n  value: Partial<Record<DimensionKey, string>>;\n}\n\n/** Entity is always required and always visible. */\nexport function DimensionPicker({ required, value, onValueChange, className }: DimensionPickerProps) {\n  const keys = React.useMemo(() => {\n    const set = new Set<DimensionKey>([\"entityId\", ...required]);\n    return [...set];\n  }, [required]);\n\n  return (\n    <div className={cn(\"flex flex-wrap gap-1\", className)}>\n      {keys.map((key) => {\n        const missing = !value[key];\n        return (\n          <label className=\"block\" key={key}>\n            <span className=\"sr-only\">{LABELS[key]}</span>\n            <select\n              aria-invalid={missing}\n              className={cn(\n                \"h-8 rounded-sm border bg-surface px-2 text-caption outline-none focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent-subtle\",\n                missing ? \"border-negative text-text-tertiary\" : \"border-border\",\n              )}\n              onChange={(e) => onValueChange({ ...value, [key]: e.target.value || undefined })}\n              value={value[key] ?? \"\"}\n            >\n              <option value=\"\">{LABELS[key]}…</option>\n              {OPTIONS[key].map((o) => (\n                <option key={o} value={o}>\n                  {o}\n                </option>\n              ))}\n            </select>\n          </label>\n        );\n      })}\n    </div>\n  );\n}\n",
      "path": "components/ledger/dimension-picker.tsx",
      "target": "components/ledger/dimension-picker.tsx",
      "type": "registry:component"
    }
  ],
  "name": "dimension-picker",
  "registryDependencies": [
    "@lopifi/theme",
    "@lopifi/accounting.types",
    "@lopifi/cn"
  ],
  "title": "DimensionPicker",
  "type": "registry:component"
}
