{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pricing-toggle",
  "type": "registry:block",
  "title": "Pricing, billing toggle",
  "description": "Up to three plans with a monthly and yearly switch that changes every price. Both prices show while editing.",
  "categories": [
    "pricing"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/badge.json",
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-c-proof.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/pricing-toggle/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/pricing-toggle/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, link, t, req } from '../_shared/schema';\n\nconst tier = z.object({\n  name: t(40),\n  monthly: t(16),\n  yearly: t(16),\n  period: t(40),\n  description: t(120),\n  features: z.array(t(80)).max(8),\n  cta: link,\n  featured: z.boolean(),\n});\n\nconst schema = z.object({\n  eyebrow: t(60),\n  title: t(120),\n  description: t(300),\n  monthlyLabel: req(24),\n  yearlyLabel: t(24),\n  saving: t(32),\n  tiers: z.array(tier).min(1).max(3),\n});\n\nexport const spec = defineSpec({\n  type: 'pricing-toggle',\n  aliases: ['pricing/toggle'],\n  name: 'Pricing, billing toggle',\n  category: 'pricing',\n  role: 'body',\n  description: 'Up to three plans with a monthly and yearly switch that changes every price. Both prices show while editing.',\n  schema,\n  defaults: {\n    eyebrow: 'Section name',\n    title: 'Say how billing can be chosen',\n    description: 'Say in one sentence what every plan includes and what the choice is about.',\n    monthlyLabel: 'Monthly',\n    yearlyLabel: 'Yearly',\n    saving: 'Save 00 %',\n    tiers: [\n      {\n        name: 'First plan',\n        monthly: '$00',\n        yearly: '$00',\n        period: 'billing period',\n        description: 'Say who this plan suits in one line',\n        features: ['Name a first feature', 'Name a feature', 'Name a third feature', 'Name a feature'],\n        cta: { label: 'Main action', href: '#start' },\n        featured: false,\n      },\n      {\n        name: 'Second plan',\n        monthly: '$00',\n        yearly: '$00',\n        period: 'per unit, per period',\n        description: 'Say who this plan suits in one line',\n        features: ['Name a first feature', 'Name a second feature', 'Name a third feature', 'Name a feature', 'Name a fifth feature'],\n        cta: { label: 'Main action', href: '#trial' },\n        featured: true,\n      },\n      {\n        name: 'Third plan',\n        monthly: '$00',\n        yearly: '$00',\n        period: 'per unit, per period',\n        description: 'Say who this plan suits in one line',\n        features: ['Name a first feature', 'Name a feature', 'Name a feature', 'Name a feature', 'Name a feature this plan adds'],\n        cta: { label: 'Second action', href: '#sales' },\n        featured: false,\n      },\n    ],\n  },\n});\n"
    },
    {
      "path": "src/blocks/pricing-toggle/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/pricing-toggle/index.tsx",
      "content": "/// <reference path=\"../../css.d.ts\" />\nimport './period.css';\nimport { useId } from 'react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { ActionLink, Container, Section, useEditing, nowrapIfShort } from '../_shared/kit';\nimport { CheckItem, Heading, useHeadingId } from '../_shared/c-proof-kit';\nimport { Badge } from '../../ui/badge';\nimport { cn } from '../../lib/utils';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\nconst COLS = { 1: '', 2: '@3xl:grid-cols-2', 3: '@4xl:grid-cols-3' } as const;\n\n// A segment is a label around a native radio: the browser keeps the pick, and period.css shows the matching price, so the toggle\n// works the same with or without script, and the block is a library row (KB-364).\nconst seg = () =>\n  cn(\n    'inline-flex min-h-11 items-center gap-2 rounded-kh px-4 text-kh-small font-medium text-kh-muted transition-colors duration-(--kh-dur) hover:text-kh-ink',\n    'focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-(--kh-focus)',\n    'cursor-pointer has-[:checked]:bg-kh-surface has-[:checked]:text-kh-ink has-[:checked]:shadow-kh-1 has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-1 has-[:focus-visible]:outline-(--kh-focus)',\n  );\n\nfunction PricingToggle({ props }: BlockProps<Props>) {\n  const id = useHeadingId(props.title);\n  const editing = useEditing();\n  const name = `kh-period-${useId()}`;\n  const n = Math.min(3, Math.max(1, props.tiers.length)) as 1 | 2 | 3;\n  return (\n    <Section labelledBy={id}>\n      <Container className=\"kh-pricing-toggle\">\n        <Heading id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} align=\"center\" />\n        <div className=\"mt-10 flex justify-center\">\n          {editing ? (\n            <p className=\"inline-flex flex-wrap items-center justify-center gap-3 rounded-kh-lg bg-kh-surface-2 p-1 text-kh-small font-medium\">\n              <Text path={['monthlyLabel']} value={props.monthlyLabel} as=\"span\" className=\"px-3 py-2\" />\n              <Text path={['yearlyLabel']} value={props.yearlyLabel} as=\"span\" className=\"px-3 py-2\" />\n              <Badge tone=\"accent\" className=\"mr-2\">\n                <Text path={['saving']} value={props.saving} as=\"span\" />\n              </Badge>\n            </p>\n          ) : props.monthlyLabel.trim() && props.yearlyLabel.trim() && (\n            // Without both names there is nothing to choose between: no toggle, and period.css shows the monthly price.\n            <fieldset className=\"inline-flex min-w-0 items-center gap-1 rounded-kh-lg bg-kh-surface-2 p-1\">\n              <legend className=\"sr-only\">{props.monthlyLabel + ' / ' + props.yearlyLabel}</legend>\n              <label className={seg()}>\n                <input type=\"radio\" name={name} value=\"monthly\" defaultChecked data-kh-css-control=\"\" className=\"sr-only\" />\n                <Text path={['monthlyLabel']} value={props.monthlyLabel} as=\"span\" />\n              </label>\n              <label className={seg()}>\n                <input type=\"radio\" name={name} value=\"yearly\" data-kh-css-control=\"\" className=\"sr-only\" />\n                <Text path={['yearlyLabel']} value={props.yearlyLabel} as=\"span\" />\n                {props.saving && (\n                  <Badge tone=\"accent\">\n                    <Text path={['saving']} value={props.saving} as=\"span\" />\n                  </Badge>\n                )}\n              </label>\n            </fieldset>\n          )}\n        </div>\n        <ul className={cn('mx-auto mt-10 grid max-w-kh-page items-stretch gap-5', COLS[n])}>\n          {props.tiers.map((tier, i) => (\n            <li key={i} className={cn('flex flex-col rounded-kh-xl border p-8', tier.featured ? 'border-kh-ink bg-kh-surface shadow-kh-3' : 'border-kh-line bg-kh-surface')}>\n              <Text path={['tiers', i, 'name']} value={tier.name} as=\"h3\" className=\"text-kh-heading font-semibold\" />\n              <Text path={['tiers', i, 'description']} value={tier.description} as=\"p\" className=\"mt-2 min-h-12 text-kh-small text-kh-muted\" />\n              <p className=\"mt-6 flex flex-wrap items-baseline gap-x-2\" aria-live=\"polite\">\n                {editing ? (\n                  <>\n                    <Text path={['tiers', i, 'monthly']} value={tier.monthly} as=\"span\" className={cn(nowrapIfShort(tier.monthly), 'text-kh-title font-semibold tabular-nums')} />\n                    <Text path={['tiers', i, 'yearly']} value={tier.yearly} as=\"span\" className={cn(nowrapIfShort(tier.yearly), 'text-kh-title font-semibold tabular-nums text-kh-muted')} />\n                  </>\n                ) : (\n                  <>\n                    <Text path={['tiers', i, 'monthly']} value={tier.monthly} as=\"span\" className={cn(nowrapIfShort(tier.monthly), 'kh-price-monthly text-kh-title font-semibold tabular-nums')} />\n                    <Text path={['tiers', i, 'yearly']} value={tier.yearly} as=\"span\" className={cn(nowrapIfShort(tier.yearly), 'kh-price-yearly text-kh-title font-semibold tabular-nums')} />\n                  </>\n                )}\n                <Text path={['tiers', i, 'period']} value={tier.period} as=\"span\" className=\"text-kh-small text-kh-muted\" />\n              </p>\n              <ActionLink path={['tiers', i, 'cta']} value={tier.cta} variant={tier.featured ? 'primary' : 'secondary'} size=\"md\" className=\"mt-6 w-full\" />\n              <ul className=\"mt-8 space-y-3 border-t border-kh-line pt-6\">\n                {tier.features.map((f, j) => (\n                  <CheckItem key={j} path={['tiers', i, 'features', j]} value={f} />\n                ))}\n              </ul>\n            </li>\n          ))}\n        </ul>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(PricingToggle);\n"
    },
    {
      "path": "src/blocks/pricing-toggle/period.css",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/pricing-toggle/period.css",
      "content": "/* The period the visitor picked is the checked radio; only its price shows. No script: the browser keeps the pick (KB-364). */\n.kh-pricing-toggle:has(input[value=\"yearly\"]:checked) .kh-price-monthly,\n.kh-pricing-toggle:not(:has(input[value=\"yearly\"]:checked)) .kh-price-yearly { display: none; }\n"
    }
  ]
}
