{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "openlmis-column-view-options",
  "title": "Column View Options",
  "description": "View menu that shows or hides a table's columns with checkboxes, and resets them to their defaults.",
  "dependencies": [
    "lucide-react@^1",
    "@base-ui/react@^1"
  ],
  "registryDependencies": [
    "button",
    "dropdown-menu"
  ],
  "files": [
    {
      "path": "registry/components/openlmis/column-view-options/column-view-options.tsx",
      "content": "\"use client\"\n\nimport { Settings2Icon } from \"lucide-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport {\n  DropdownMenu,\n  DropdownMenuCheckboxItem,\n  DropdownMenuContent,\n  DropdownMenuGroup,\n  DropdownMenuItem,\n  DropdownMenuLabel,\n  DropdownMenuSeparator,\n  DropdownMenuTrigger,\n} from \"@/components/ui/dropdown-menu\"\n\nexport type ColumnViewOption = {\n  id: string\n  label: string\n}\n\n/** Column id to whether it shows; a column missing from the map shows. */\nexport type ColumnVisibility = Record<string, boolean>\n\nexport type ColumnViewLabels = {\n  view: string\n  toggleColumns: string\n  resetColumns: string\n}\n\nconst defaultLabels: ColumnViewLabels = {\n  view: \"View\",\n  toggleColumns: \"Toggle Columns\",\n  resetColumns: \"Reset Columns\",\n}\n\ntype ColumnViewOptionsProps = {\n  /** The columns a user may hide; leave out the identifying column and actions, which always show. */\n  columns: ColumnViewOption[]\n  visibility: ColumnVisibility\n  onVisibilityChange: (visibility: ColumnVisibility) => void\n  /** Returns every column to its default, e.g. the one that fits the room. */\n  onReset?: () => void\n  labels?: Partial<ColumnViewLabels>\n}\n\nexport function ColumnViewOptions({\n  columns,\n  visibility,\n  onVisibilityChange,\n  onReset,\n  labels: labelOverrides,\n}: ColumnViewOptionsProps) {\n  const labels = { ...defaultLabels, ...labelOverrides }\n  const isVisible = (id: string) => visibility[id] !== false\n\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger render={<Button variant=\"outline\" />}>\n        <Settings2Icon data-icon=\"inline-start\" />\n        {labels.view}\n      </DropdownMenuTrigger>\n      <DropdownMenuContent align=\"end\" className=\"w-auto\">\n        <DropdownMenuGroup>\n          <DropdownMenuLabel>{labels.toggleColumns}</DropdownMenuLabel>\n          {columns.map((column) => (\n            <DropdownMenuCheckboxItem\n              checked={isVisible(column.id)}\n              key={column.id}\n              onCheckedChange={(checked) =>\n                onVisibilityChange({ ...visibility, [column.id]: checked })\n              }\n            >\n              {column.label}\n            </DropdownMenuCheckboxItem>\n          ))}\n        </DropdownMenuGroup>\n        {onReset && (\n          <>\n            <DropdownMenuSeparator />\n            <DropdownMenuItem onClick={onReset} variant=\"destructive\">\n              {labels.resetColumns}\n            </DropdownMenuItem>\n          </>\n        )}\n      </DropdownMenuContent>\n    </DropdownMenu>\n  )\n}",
      "type": "registry:component",
      "target": "components/openlmis/column-view-options.tsx"
    }
  ],
  "cssVars": {
    "light": {
      "destructive": "oklch(0.577 0.245 27.325)",
      "destructive-foreground": "oklch(0.985 0 0)",
      "success": "oklch(0.596 0.145 163.225)",
      "success-foreground": "oklch(0.985 0 0)",
      "warning": "oklch(0.666 0.179 58.318)",
      "warning-foreground": "oklch(0.985 0 0)",
      "info": "oklch(0.55 0.13 237)",
      "info-foreground": "oklch(0.985 0 0)"
    },
    "dark": {
      "destructive": "oklch(0.704 0.191 22.216)",
      "destructive-foreground": "oklch(0.21 0.04 25)",
      "success": "oklch(0.696 0.17 162.48)",
      "success-foreground": "oklch(0.21 0.04 163)",
      "warning": "oklch(0.769 0.188 70.08)",
      "warning-foreground": "oklch(0.22 0.04 60)",
      "info": "oklch(0.7 0.14 237)",
      "info-foreground": "oklch(0.2 0.04 240)"
    }
  },
  "meta": {
    "project": "openlmis",
    "height": "320px"
  },
  "docs": "Requires a `base-*` style in components.json (the `shadcn init` default). Legacy `new-york`/`radix-*` styles install Radix primitives, which reject the `render` prop this item uses.",
  "categories": [
    "data-table"
  ],
  "type": "registry:component"
}
