{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "grid-list-controls-preskok-demo",
  "registryDependencies": [
    "https://ui-three-mu.vercel.app/r/grid-list.json",
    "https://ui-three-mu.vercel.app/r/switch.json"
  ],
  "files": [
    {
      "path": "registry/preskok/examples/grid-list-controls-preskok-demo.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\n\nimport {\n  GridList,\n  GridListDescription,\n  GridListHeader,\n  GridListItem,\n  GridListLabel,\n  GridListSection,\n  GridListSpacer,\n  GridListStart,\n} from \"@/components/ui/preskok-ui/grid-list\"\nimport { Switch } from \"@/components/ui/preskok-ui/switch\"\n\nconst ALL_BRANDS_KEY = \"all\"\n\nexport default function GridListControlsPreskokDemo() {\n  const [officialBrands, setOfficialBrands] = useState(\n    new Set([\"Audi\", \"Volkswagen\"])\n  )\n\n  const isEveryBrandOfficial = officialBrands.size === brands.length\n\n  const setBrand = (brand: string, isOfficial: boolean) => {\n    setOfficialBrands((previous) => {\n      const next = new Set(previous)\n\n      if (isOfficial) {\n        next.add(brand)\n      } else {\n        next.delete(brand)\n      }\n\n      return next\n    })\n  }\n\n  const setEveryBrand = (isOfficial: boolean) => {\n    setOfficialBrands(new Set(isOfficial ? brands : []))\n  }\n\n  return (\n    <GridList\n      variant=\"bordered\"\n      aria-label=\"Official dealer per brand\"\n      className=\"w-sm max-w-full\"\n      // The whole row toggles its switch, so the label is as easy to hit as the switch.\n      onAction={(key) => {\n        if (key === ALL_BRANDS_KEY) {\n          setEveryBrand(!isEveryBrandOfficial)\n        } else {\n          setBrand(String(key), !officialBrands.has(String(key)))\n        }\n      }}\n    >\n      <GridListSection>\n        <GridListHeader>Official dealer</GridListHeader>\n        <GridListItem id={ALL_BRANDS_KEY} textValue=\"All brands\">\n          <GridListStart>\n            <div>\n              <GridListLabel>All brands</GridListLabel>\n              <GridListDescription>\n                {officialBrands.size} of {brands.length} on\n              </GridListDescription>\n            </div>\n          </GridListStart>\n          <GridListSpacer />\n          <Switch\n            aria-label=\"Official dealer for all brands\"\n            className=\"sm:*:data-[slot=indicator]:mt-0\"\n            isSelected={isEveryBrandOfficial}\n            onChange={setEveryBrand}\n          />\n        </GridListItem>\n        {brands.map((brand) => (\n          <GridListItem key={brand} id={brand} textValue={brand}>\n            <GridListLabel className=\"font-normal\">{brand}</GridListLabel>\n            <GridListSpacer />\n            <Switch\n              aria-label={`Official dealer for ${brand}`}\n              className=\"sm:*:data-[slot=indicator]:mt-0\"\n              isSelected={officialBrands.has(brand)}\n              onChange={(isOfficial) => setBrand(brand, isOfficial)}\n            />\n          </GridListItem>\n        ))}\n      </GridListSection>\n    </GridList>\n  )\n}\n\nconst brands = [\"Audi\", \"BMW\", \"Citroën\", \"Volkswagen\", \"Škoda\"]\n",
      "type": "registry:example"
    }
  ],
  "type": "registry:example"
}