{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "block-product-form",
  "type": "registry:block",
  "title": "Product form",
  "description": "Adding a product to the catalogue on a raised page: details, photos with a cover, pricing with a live margin, options that make variants and inventory as cards, either beside its sales channels and a live preview (split) or alone in a centred column with the actions in a bar at the foot (centered).",
  "dependencies": [
    "@remixicon/react@^4.9.0"
  ],
  "registryDependencies": [
    "https://wideset.co/r/app-shell.json",
    "https://wideset.co/r/avatar.json",
    "https://wideset.co/r/block-styles.json",
    "https://wideset.co/r/breadcrumbs.json",
    "https://wideset.co/r/button.json",
    "https://wideset.co/r/card.json",
    "https://wideset.co/r/checkbox.json",
    "https://wideset.co/r/chip.json",
    "https://wideset.co/r/divider.json",
    "https://wideset.co/r/dropdown-menu.json",
    "https://wideset.co/r/file-upload.json",
    "https://wideset.co/r/form-field.json",
    "https://wideset.co/r/icon-button.json",
    "https://wideset.co/r/inline-alert.json",
    "https://wideset.co/r/list-item.json",
    "https://wideset.co/r/select.json",
    "https://wideset.co/r/sidebar.json",
    "https://wideset.co/r/status-badge.json",
    "https://wideset.co/r/table.json",
    "https://wideset.co/r/tag.json",
    "https://wideset.co/r/text-input.json",
    "https://wideset.co/r/textarea.json",
    "https://wideset.co/r/toast.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/product-form/brand-mark.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/brand-mark.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nconst TILE =\n  'M0 16C0 8.45753 0 4.68629 2.34315 2.34315C4.68629 0 8.45753 0 16 0C23.5425 0 27.3137 0 29.6569 2.34315C32 4.68629 32 8.45753 32 16C32 23.5425 32 27.3137 29.6569 29.6569C27.3137 32 23.5425 32 16 32C8.45753 32 4.68629 32 2.34315 29.6569C0 27.3137 0 23.5425 0 16Z';\n\n/**\n * Orbit's mark: a planet and its ring on the inverse tile, so it inverts in dark mode. It takes\n * the size of its place (32px in a sidebar, 36px in a larger switcher). Decorative beside the\n * product's name; give it a `label` when it stands alone.\n */\nexport function BrandMark({ className, label }: { className?: string; label?: string }) {\n  return (\n    <svg\n      viewBox=\"0 0 32 32\"\n      role={label ? 'img' : undefined}\n      aria-label={label}\n      aria-hidden={label ? undefined : true}\n      className={cn('size-ws-14 shrink-0', className)}\n    >\n      <path d={TILE} className=\"fill-(--ws-static-fill-inverse-background)\" />\n      <ellipse\n        cx=\"16\"\n        cy=\"16\"\n        rx=\"10.5\"\n        ry=\"4\"\n        transform=\"rotate(-28 16 16)\"\n        strokeWidth=\"1.75\"\n        className=\"fill-none stroke-(--ws-static-text-inverse-strong)\"\n      />\n      <circle cx=\"16\" cy=\"16\" r=\"4.75\" className=\"fill-(--ws-static-text-inverse-strong)\" />\n    </svg>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/cover-placeholder.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/cover-placeholder.tsx",
      "content": "'use client';\n\n// TODO(custom): a neutral image placeholder filling Card.Media; Wideset has no image placeholder.\nimport { RiImageAddLine, RiImageLine } from '@remixicon/react';\n\nimport type { Photo } from './data';\n\n/** The cover's stand-in: an image icon for the added photo, or a note that there is none yet. */\nexport function CoverPlaceholder({ cover }: { cover: Photo | undefined }) {\n  return (\n    <div className=\"bg-ws-static-alpha-subtle gap-ws-3 flex size-full flex-col items-center justify-center\">\n      {cover ? (\n        <RiImageLine\n          role=\"img\"\n          aria-label={`Cover: ${cover.name}`}\n          className=\"size-ws-12 text-ws-static-subtle\"\n        />\n      ) : (\n        <>\n          <RiImageAddLine aria-hidden=\"true\" className=\"size-ws-12 text-ws-static-subtle\" />\n          <span className=\"typography-caption-md text-ws-static-subtle\">No cover yet</span>\n        </>\n      )}\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/data.ts",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/data.ts",
      "content": "import {\n  type RemixiconComponentType,\n  RiBankCardLine,\n  RiContactsBook3Line,\n  RiHandCoinLine,\n  RiHome5Line,\n  RiInbox2Line,\n  RiKey2Line,\n  RiLineChartLine,\n  RiPieChart2Line,\n  RiPlugLine,\n  RiPriceTag3Fill,\n  RiPriceTag3Line,\n  RiQuestionLine,\n  RiSettings3Line,\n  RiTeamLine,\n} from '@remixicon/react';\n\n/*\n  A product being added to Lumen Studio's catalogue: a wall mount for the Lumen Display and the\n  Lumen Hub it already sells (see Orders), in three sizes. It is half way: the details, three\n  photos and the prices are in, nothing is saved yet. Today is 10 November 2026. The fields hold\n  what was typed, as text; money is read from them into whole cents when a figure is needed.\n*/\n\n/** The product is Orbit; the workspace selling through it is Lumen Studio. */\nexport const product = { name: 'Orbit' };\nexport const workspace = { name: 'Lumen Studio', initials: 'LS' };\nexport const account = { name: 'Maya Okafor', email: 'maya@lumenstudio.co', initials: 'MO' };\n\nexport type NavLink = {\n  id: string;\n  label: string;\n  icon: RemixiconComponentType;\n  /** The icon while the page is open (a line icon swaps for its fill). */\n  activeIcon?: RemixiconComponentType;\n};\n\nexport const mainLinks: NavLink[] = [\n  { id: 'home', label: 'Home', icon: RiHome5Line },\n  { id: 'inbox', label: 'Inbox', icon: RiInbox2Line },\n  { id: 'customers', label: 'Customers', icon: RiContactsBook3Line },\n  { id: 'deals', label: 'Deals', icon: RiHandCoinLine },\n  { id: 'catalogue', label: 'Catalogue', icon: RiPriceTag3Line, activeIcon: RiPriceTag3Fill },\n  { id: 'revenue', label: 'Revenue', icon: RiLineChartLine },\n  { id: 'reports', label: 'Reports', icon: RiPieChart2Line },\n];\n\nexport const settingsLinks: NavLink[] = [\n  { id: 'general', label: 'General', icon: RiSettings3Line },\n  { id: 'members', label: 'Members', icon: RiTeamLine },\n  { id: 'billing', label: 'Billing', icon: RiBankCardLine },\n  { id: 'integrations', label: 'Integrations', icon: RiPlugLine },\n  { id: 'api-keys', label: 'API keys', icon: RiKey2Line },\n];\n\nexport const helpLink: NavLink = { id: 'help', label: 'Help and support', icon: RiQuestionLine };\n\n/** How the catalogue groups what Lumen Studio sells. */\nexport const categories = [\n  { value: 'hardware', label: 'Hardware' },\n  { value: 'accessories', label: 'Accessories' },\n  { value: 'licences', label: 'Licences' },\n  { value: 'services', label: 'Services' },\n];\n\n/** Lumen Studio Ltd is a UK business: the VAT rate a sale carries. */\nexport const taxClasses = [\n  { value: 'standard', label: 'Standard rate, 20%' },\n  { value: 'reduced', label: 'Reduced rate, 5%' },\n  { value: 'zero', label: 'Zero rate' },\n  { value: 'exempt', label: 'Exempt' },\n];\n\n/** Where a published product can be bought. */\nexport const channels = [\n  { id: 'store', label: 'Online store' },\n  { id: 'quotes', label: 'Sales quotes' },\n  { id: 'partners', label: 'Partner portal' },\n];\n\n/** The longest description the catalogue keeps. */\nexport const DESCRIPTION_LIMIT = 1000;\n/** A product shows this many options at most, as most shops do. */\nexport const OPTION_LIMIT = 3;\n\nexport type Status = 'draft' | 'active';\n\n/** A photo added to the product. Blocks ship no images, so it is known by its file name. */\nexport type Photo = { id: string; name: string };\n\n/** A choice the buyer makes (Size) and the values it takes (S, M, L). */\nexport type ProductOption = { id: string; name: string; values: string[] };\n\n/** What one variant sells for and how many are on the shelf, as typed. */\nexport type VariantFields = { price: string; stock: string };\n\nexport type ProductDraft = {\n  name: string;\n  /** One line under the name in lists. */\n  summary: string;\n  description: string;\n  category: string;\n  /** In order: the first is the cover. */\n  photos: Photo[];\n  price: string;\n  compareAt: string;\n  cost: string;\n  taxClass: string;\n  hasOptions: boolean;\n  options: ProductOption[];\n  /**\n   * By variant key, the combination's options and values (`variantKey([['size', 'M'],\n   * ['colour', 'Black']])`), as typed: two combinations never share an entry, even when their\n   * names read alike. See `variantFields` for one not in here.\n   */\n  variants: Record<string, VariantFields>;\n  sku: string;\n  stock: string;\n  trackStock: boolean;\n  /** The ids of the channels it is sold in. */\n  channels: string[];\n};\n\nexport const initialDraft: ProductDraft = {\n  name: 'Lumen Wall Mount',\n  summary: 'Tilting wall mount for the Lumen Display and Lumen Hub.',\n  description:\n    'A steel mount that holds a Lumen Display or a Lumen Hub flat against the wall or tilted down by up to 15 degrees, so the camera above it sees the whole table. Cables run inside the arm and out of sight. Fixings for brick, concrete and plasterboard walls are in the box, with a paper template to drill by.\\n\\nS fits screens up to 32 inches, M up to 55 and L up to 75.',\n  category: 'accessories',\n  photos: [\n    { id: 'front', name: 'mount-front.jpg' },\n    { id: 'side', name: 'mount-side.jpg' },\n    { id: 'room', name: 'mount-in-room.jpg' },\n  ],\n  price: '149.00',\n  compareAt: '',\n  cost: '62.00',\n  taxClass: 'standard',\n  hasOptions: true,\n  options: [{ id: 'size', name: 'Size', values: ['S', 'M', 'L'] }],\n  variants: {\n    [variantKey([['size', 'S']])]: { price: '129.00', stock: '24' },\n    [variantKey([['size', 'M']])]: { price: '149.00', stock: '40' },\n    [variantKey([['size', 'L']])]: { price: '179.00', stock: '12' },\n  },\n  sku: 'LS-MNT-01',\n  stock: '',\n  trackStock: true,\n  channels: ['store', 'quotes'],\n};\n\n/** One option's value in a combination: the option's id, then the value. */\nexport type VariantPart = [optionId: string, value: string];\n\n/**\n * A combination's identity: each option's id with its value, in option order, never its display\n * name. The ids keep \"S\" of a Colour apart from \"S\" of a removed Size.\n */\nexport function variantKey(parts: VariantPart[]) {\n  return JSON.stringify(parts);\n}\n\n/** One combination of option values: its key for the draft, its name for people. */\nexport type Variant = { key: string; name: string; parts: VariantPart[] };\n\n/**\n * The variants the options make: every combination of their values, in order (\"S / Black\",\n * \"S / White\", \"M / Black\"…). An option with no values yet adds nothing.\n */\nexport function variantsOf(options: ProductOption[]): Variant[] {\n  return options\n    .filter((option) => option.values.length > 0)\n    .reduce<VariantPart[][]>(\n      (combos, option) =>\n        combos.length === 0\n          ? option.values.map((value) => [[option.id, value]])\n          : combos.flatMap((combo) =>\n              option.values.map((value): VariantPart[] => [...combo, [option.id, value]]),\n            ),\n      [],\n    )\n    .map((parts) => ({\n      key: variantKey(parts),\n      name: parts.map(([, value]) => value).join(' / '),\n      parts,\n    }));\n}\n\n/**\n * A variant's price and stock: what was typed for it; else, for a new combination, the price of\n * the nearest variant it grew from (\"S / Black / Steel\" from \"S / Black\", else from \"S\") or the\n * product's, and no stock yet.\n */\nexport function variantFields(draft: ProductDraft, variant: Variant): VariantFields {\n  const typed = draft.variants[variant.key];\n  if (typed) return typed;\n  for (let length = variant.parts.length - 1; length > 0; length -= 1) {\n    const parent = draft.variants[variantKey(variant.parts.slice(0, length))];\n    if (parent) return { price: parent.price, stock: '' };\n  }\n  return { price: draft.price, stock: '' };\n}\n"
    },
    {
      "path": "src/blocks/product-form/details-section.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/details-section.tsx",
      "content": "'use client';\n\nimport { FormField } from '@/components/ui/wideset/form-field/FormField';\nimport { Select } from '@/components/ui/wideset/select/Select';\nimport { Textarea } from '@/components/ui/wideset/textarea/Textarea';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\n\nimport { categories, DESCRIPTION_LIMIT, type ProductDraft } from './data';\nimport { FormSection } from './form-section';\nimport { formatCount } from './format';\nimport type { Errors } from './validate';\n\ntype DetailsSectionProps = {\n  /** Prefix for the field ids, so a failed save can focus one. */\n  id: string;\n  draft: ProductDraft;\n  errors: Errors;\n  onChange: (patch: Partial<ProductDraft>) => void;\n};\n\n/**\n * What the product is: its name, the line under it in lists, the longer description with a count\n * of what is left, and where it sits in the catalogue. The name is the one field a draft needs.\n */\nexport function DetailsSection({ id, draft, errors, onChange }: DetailsSectionProps) {\n  return (\n    <FormSection\n      title=\"Details\"\n      description=\"What customers read about it, in lists and on its page.\"\n    >\n      <FormField label=\"Name\" htmlFor={`${id}-name`} required errorText={errors.name}>\n        <TextInput\n          id={`${id}-name`}\n          name=\"name\"\n          size=\"sm\"\n          required\n          autoComplete=\"off\"\n          variant={errors.name ? 'danger' : 'primary'}\n          value={draft.name}\n          onChange={(event) => onChange({ name: event.target.value })}\n        />\n      </FormField>\n      <FormField\n        label=\"Short description\"\n        htmlFor={`${id}-summary`}\n        helperText=\"One line under the name in lists and on quotes.\"\n      >\n        <TextInput\n          id={`${id}-summary`}\n          name=\"summary\"\n          size=\"sm\"\n          maxLength={120}\n          autoComplete=\"off\"\n          value={draft.summary}\n          onChange={(event) => onChange({ summary: event.target.value })}\n        />\n      </FormField>\n      <FormField\n        label=\"Description\"\n        htmlFor={`${id}-description`}\n        aside={\n          <span className=\"tabular-nums\">\n            {formatCount(draft.description.length)} / {formatCount(DESCRIPTION_LIMIT)}\n          </span>\n        }\n      >\n        <Textarea\n          id={`${id}-description`}\n          name=\"description\"\n          size=\"sm\"\n          rows={6}\n          maxLength={DESCRIPTION_LIMIT}\n          value={draft.description}\n          onChange={(event) => onChange({ description: event.target.value })}\n        />\n      </FormField>\n      <div className=\"gap-ws-9 grid grid-cols-2\">\n        <FormField label=\"Category\" htmlFor={`${id}-category`}>\n          <Select\n            id={`${id}-category`}\n            name=\"category\"\n            size=\"sm\"\n            preset=\"border\"\n            className=\"w-full\"\n            placeholder=\"Choose a category\"\n            options={categories}\n            value={draft.category}\n            onValueChange={(category) => onChange({ category })}\n          />\n        </FormField>\n      </div>\n    </FormSection>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/form-section.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/form-section.tsx",
      "content": "'use client';\n\nimport { Card } from '@/components/ui/wideset/card/Card';\nimport { type ReactNode, useId } from 'react';\n\n/**\n * One part of the form as a bordered card: a 16px title and one line saying what it is for in\n * the header, the fields under it. Each section is a container, so the form reads as a stack of\n * jobs to do, the same in both layouts. The title names the region.\n */\nexport function FormSection({\n  title,\n  description,\n  children,\n}: {\n  title: string;\n  description: ReactNode;\n  children: ReactNode;\n}) {\n  const id = useId();\n\n  return (\n    <Card role=\"region\" aria-labelledby={id}>\n      <Card.Header>\n        <div className=\"gap-ws-2 flex flex-col\">\n          <h2 id={id} className=\"typography-label-strong-md text-ws-static-strong\">\n            {title}\n          </h2>\n          <p className=\"typography-body-md text-ws-static-subtle\">{description}</p>\n        </div>\n      </Card.Header>\n      {/* Card.Content keeps 10px free on the right for a scrollbar; the padding gives it back, so\n          the fields end where the header's line does. */}\n      <Card.Content contentClassName=\"pr-ws-6\">\n        <div className=\"gap-ws-11 flex flex-col\">{children}</div>\n      </Card.Content>\n    </Card>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/format.ts",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/format.ts",
      "content": "// One locale for the whole screen; swap it for the user's.\nconst LOCALE = 'en-US';\n\nconst usd = new Intl.NumberFormat(LOCALE, { style: 'currency', currency: 'USD' });\nconst decimal = new Intl.NumberFormat(LOCALE, {\n  minimumFractionDigits: 2,\n  maximumFractionDigits: 2,\n});\nconst percent = new Intl.NumberFormat(LOCALE, { style: 'percent', maximumFractionDigits: 1 });\nconst count = new Intl.NumberFormat(LOCALE);\n\n/** Money is kept in whole cents: 14900 → $149.00. */\nexport const formatUsd = (cents: number) => usd.format(cents / 100);\n/** The same without the sign, for a field that shows `$` beside it: 14900 → 149.00. */\nexport const formatAmount = (cents: number) => decimal.format(cents / 100);\n/** What was typed into such a field, in cents: `1,299.5` → 129950. Empty or not a number: NaN. */\nexport const parseAmount = (text: string) =>\n  text.trim() ? Math.round(Number(text.replace(/,/g, '')) * 100) : NaN;\n/** 0.584 → 58.4%. */\nexport const formatPercent = (rate: number) => percent.format(rate);\n/** 1000 → 1,000. */\nexport const formatCount = (value: number) => count.format(value);\n\n/** \"a name\", \"a name and a price\", \"a name, a price and a photo\". */\nexport const listSentence = (items: string[]) =>\n  items.length < 2\n    ? (items[0] ?? '')\n    : `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}`;\n"
    },
    {
      "path": "src/blocks/product-form/index.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/index.tsx",
      "content": "'use client';\n\nimport '@/styles/wideset-blocks.css';\n\nimport { RiSideBarLine } from '@remixicon/react';\nimport { AppShell } from '@/components/ui/wideset/app-shell/AppShell';\nimport { Breadcrumbs } from '@/components/ui/wideset/breadcrumbs/Breadcrumbs';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { cn } from '@/lib/wideset/utils';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { InlineAlert } from '@/components/ui/wideset/inline-alert/InlineAlert';\nimport { ToastProvider, useToast } from '@/components/ui/wideset/toast/Toast.context';\nimport { useEffect, useId, useRef, useState } from 'react';\n\nimport { channels, initialDraft, type ProductDraft, type Status } from './data';\nimport { DetailsSection } from './details-section';\nimport { listSentence } from './format';\nimport { InventorySection } from './inventory-section';\nimport { ListPreview } from './list-preview';\nimport { MediaSection } from './media-section';\nimport { OptionsSection } from './options-section';\nimport { PageHeader } from './page-header';\nimport { PricingSection } from './pricing-section';\nimport { SalesChannels } from './sales-channels';\nimport { SaveBar } from './save-bar';\nimport { ProductFormSidebar } from './sidebar';\nimport { type ErrorField, MISSING, validate } from './validate';\n\n/** The two ways to lay the form out: beside where it sells and its preview, or alone, centred. */\nexport type ProductFormLayout = 'split' | 'centered';\n\n/**\n * The page's column per layout: the header and the body share its edges. Centred, it narrows to\n * a 42rem form (46rem less its padding), a comfortable line for labels and fields.\n */\nconst COLUMN: Record<ProductFormLayout, string> = {\n  split: 'px-ws-14 mx-auto w-full max-w-[80rem]',\n  centered: 'px-ws-14 mx-auto w-full max-w-[46rem]',\n};\n\n/** The order a failed save looks for its first field in: the order of the page. */\nconst FIELD_ORDER = Object.keys(MISSING) as ErrorField[];\n\n/** What the header's line says about where the product stands. */\nfunction standing(saved: boolean, status: Status, channelIds: string[]) {\n  if (!saved) return 'Add something Lumen Studio sells. It goes on sale once it is published.';\n  if (status === 'draft') return 'A draft: only your team can see it until it is published.';\n  const names = channels.filter((c) => channelIds.includes(c.id)).map((c) => c.label);\n  return names.length\n    ? `On sale in ${listSentence(names)}.`\n    : 'Published, but in no sales channel yet.';\n}\n\n/**\n * The page inside the toast provider. Split: the form's sections down the left, where it sells and\n * how it looks in a list beside it, the actions in the header. Centred: the same sections and\n * where it sells in one column, the actions in a bar at the card's foot. Both have the same\n * actions and no status control: a draft is saved or published, a product on sale is unpublished\n * or saved, so each button says what it does and the badge by the title says where it stands. The\n * screen holds the draft, so the preview, the margin and the variants follow every keystroke;\n * errors wait for the first try at saving, then follow what is typed.\n */\nfunction ProductFormPage({ layout, collapsed, onToggleSidebar, sidebarId }: PageProps) {\n  const { showToast } = useToast();\n  const id = useId();\n  const formId = `${id}-form`;\n\n  const [draft, setDraft] = useState(initialDraft);\n  const [status, setStatus] = useState<Status>('draft');\n  /** The name it was last saved under: the page's title from then on. */\n  const [savedName, setSavedName] = useState<string | null>(null);\n  /** The save that was tried and stopped at a field; its checks then follow the typing. */\n  const [attempt, setAttempt] = useState<'draft' | 'publish' | null>(null);\n  const [pending, setPending] = useState<'draft' | 'publish' | null>(null);\n\n  const errors = attempt ? validate(draft, attempt === 'publish') : {};\n  const missing = FIELD_ORDER.filter((field) => errors[field]);\n  const update = (patch: Partial<ProductDraft>) => setDraft({ ...draft, ...patch });\n\n  // Cleared on unmount, so the stand-in request never lands on a closed screen.\n  const timer = useRef<number>(undefined);\n  useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  // A timeout stands in for the request; a real screen awaits it and, when it fails, keeps every\n  // field as it was and says so in an InlineAlert above the form.\n  function save(publishing: boolean) {\n    const found = validate(draft, publishing);\n    const first = FIELD_ORDER.find((field) => found[field]);\n    setAttempt(publishing ? 'publish' : 'draft');\n    if (first) return document.getElementById(`${id}-${first}`)?.focus();\n\n    const name = draft.name.trim();\n    setPending(publishing ? 'publish' : 'draft');\n    timer.current = window.setTimeout(() => {\n      setPending(null);\n      setAttempt(null);\n      setSavedName(name);\n      setStatus(publishing ? 'active' : 'draft');\n      showToast({\n        status: 'success',\n        content: !publishing\n          ? 'Draft saved'\n          : status === 'active'\n            ? 'Changes saved'\n            : `${name} is on sale`,\n      });\n    }, 700);\n  }\n\n  function unpublish() {\n    setStatus('draft');\n    showToast({ content: `${savedName} is a draft again` });\n  }\n\n  const title = savedName ?? 'New product';\n  const centered = layout === 'centered';\n  const busy = pending !== null;\n\n  // The bordered button beside the filled one: a draft is saved as one, a product on sale is\n  // taken off sale. Unpublish applies at once and leaves the fields as they are.\n  const secondary =\n    status === 'draft' ? (\n      <Button\n        size=\"sm\"\n        variant=\"secondary\"\n        preset=\"border\"\n        disabled={busy}\n        onClick={() => save(false)}\n      >\n        {pending === 'draft' ? 'Saving…' : 'Save draft'}\n      </Button>\n    ) : (\n      <Button size=\"sm\" variant=\"secondary\" preset=\"border\" disabled={busy} onClick={unpublish}>\n        Unpublish\n      </Button>\n    );\n  const publish = (\n    <Button size=\"sm\" type=\"submit\" form={formId} disabled={busy}>\n      {pending === 'publish'\n        ? status === 'active'\n          ? 'Saving…'\n          : 'Publishing…'\n        : status === 'active'\n          ? 'Save changes'\n          : 'Publish'}\n    </Button>\n  );\n  const salesChannels = (\n    <SalesChannels\n      selected={draft.channels}\n      onChange={(selected) => update({ channels: selected })}\n    />\n  );\n\n  // Both layouts share this form: the alert, then one card a section, in the order it is filled.\n  const form = (\n    <form\n      id={formId}\n      noValidate\n      aria-label=\"Product\"\n      onSubmit={(event) => {\n        event.preventDefault();\n        save(true);\n      }}\n      className=\"gap-ws-12 flex flex-col\"\n    >\n      {missing.length > 0 && (\n        <InlineAlert\n          status=\"error\"\n          persistent\n          title={attempt === 'publish' ? 'Can’t publish yet' : 'Can’t save the draft yet'}\n          message={`Add ${listSentence(missing.map((field) => MISSING[field]))}.`}\n        />\n      )}\n      <DetailsSection id={id} draft={draft} errors={errors} onChange={update} />\n      <MediaSection id={id} photos={draft.photos} errors={errors} onChange={update} />\n      <PricingSection id={id} draft={draft} errors={errors} onChange={update} />\n      <OptionsSection id={id} draft={draft} onChange={update} />\n      <InventorySection id={id} draft={draft} onChange={update} />\n      {/* Centred, where it sells is the last thing to decide before publishing. */}\n      {centered && salesChannels}\n    </form>\n  );\n\n  return (\n    <main className=\"bg-ws-static-foreground rounded-ws-container-lg shadow-ws-low my-ws-7 mr-ws-7 ml-ws-5 flex min-w-0 flex-1 flex-col overflow-hidden\">\n      <div className=\"h-ws-18 border-ws-static-base flex shrink-0 items-center border-b\">\n        {/* The bar belongs to the surround: it runs edge to edge. The sidebar's toggle is pulled\n            left so its glyph, not its box, sits 20px from the edge; the crumbs follow it. */}\n        <div className=\"gap-ws-5 px-ws-11 flex w-full items-center\">\n          <IconButton\n            icon={RiSideBarLine}\n            variant=\"secondary\"\n            preset=\"ghost\"\n            size=\"sm\"\n            iconClassName=\"text-ws-static-subtle size-ws-9\"\n            aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}\n            aria-expanded={!collapsed}\n            aria-controls={sidebarId}\n            onClick={onToggleSidebar}\n            className=\"-ml-ws-5\"\n          />\n          <Breadcrumbs separator=\"arrow\">\n            <Breadcrumbs.Item asChild>\n              <a href=\"#catalogue\">Catalogue</a>\n            </Breadcrumbs.Item>\n            <Breadcrumbs.Item>{title}</Breadcrumbs.Item>\n          </Breadcrumbs>\n        </div>\n      </div>\n\n      {/* The page scrolls inside the card, so the card's corners stay put. `relative` keeps the\n          hidden form inputs Select and Checkbox render (absolute) inside it: without it they\n          escape and make the window scroll. */}\n      <div className=\"ws-scrollbar relative min-h-0 flex-1 overflow-y-auto\">\n        <div className={cn(COLUMN[layout], 'gap-ws-14 pt-ws-14 pb-ws-16 flex flex-col')}>\n          <PageHeader\n            title={title}\n            status={savedName ? status : undefined}\n            description={standing(Boolean(savedName), status, draft.channels)}\n          >\n            {!centered && (\n              <>\n                {secondary}\n                {publish}\n              </>\n            )}\n          </PageHeader>\n\n          {centered ? (\n            form\n          ) : (\n            <div className=\"gap-ws-16 grid grid-cols-1 items-start lg:grid-cols-[minmax(0,44rem)_20rem] lg:justify-between\">\n              {form}\n              <aside\n                aria-label=\"Sales channels and preview\"\n                className=\"gap-ws-12 lg:top-ws-14 flex flex-col lg:sticky\"\n              >\n                {salesChannels}\n                <ListPreview draft={draft} />\n              </aside>\n            </div>\n          )}\n        </div>\n      </div>\n\n      {/* Centred, the actions leave the header for a bar pinned to the card's foot, in view down\n          the whole form. */}\n      {centered && (\n        <SaveBar column={COLUMN.centered}>\n          <Button size=\"sm\" variant=\"secondary\" preset=\"ghost\" asChild>\n            <a href=\"#catalogue\">Cancel</a>\n          </Button>\n          {secondary}\n          {publish}\n        </SaveBar>\n      )}\n    </main>\n  );\n}\n\ntype PageProps = {\n  layout: ProductFormLayout;\n  collapsed: boolean;\n  onToggleSidebar: () => void;\n  sidebarId: string;\n};\n\n/**\n * Product form (Inset direction): adding a product to the catalogue on the raised page beside the\n * workspace sidebar. The form is a stack of cards in the order it is filled (details, media,\n * pricing, options, inventory). `split` (the default) keeps where it sells and a preview of its\n * catalogue card in view beside it, the actions in the header; `centered` puts the form alone in\n * the middle with where it sells last, the actions in a bar at the card's foot. Save draft keeps\n * it to the team; Publish, the page's one filled button, checks what a customer needs and puts it\n * on sale. Once on sale the two buttons read Unpublish and Save changes.\n */\nexport default function ProductForm({ layout = 'split' }: { layout?: ProductFormLayout }) {\n  const sidebarId = useId();\n  const [collapsed, setCollapsed] = useState(false);\n\n  // Centred, the save bar holds the foot of the card, so confirmations come in at the top right,\n  // over the empty end of the bar above the page.\n  return (\n    <ToastProvider position={layout === 'centered' ? 'top-right' : 'bottom-center'}>\n      <AppShell className=\"ws-block-utility\" direction=\"inset\">\n        <ProductFormSidebar id={sidebarId} collapsed={collapsed} onCollapsedChange={setCollapsed} />\n        <ProductFormPage\n          layout={layout}\n          collapsed={collapsed}\n          onToggleSidebar={() => setCollapsed(!collapsed)}\n          sidebarId={sidebarId}\n        />\n      </AppShell>\n    </ToastProvider>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/inventory-section.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/inventory-section.tsx",
      "content": "'use client';\n\nimport { Checkbox } from '@/components/ui/wideset/checkbox/Checkbox';\nimport { FormField } from '@/components/ui/wideset/form-field/FormField';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\n\nimport type { ProductDraft } from './data';\nimport { FormSection } from './form-section';\n\ntype InventorySectionProps = {\n  id: string;\n  draft: ProductDraft;\n  onChange: (patch: Partial<ProductDraft>) => void;\n};\n\n/**\n * How the product is counted: its stock number for packing slips, how many are on the shelf and\n * whether Orbit counts them at all. With options, stock is kept per variant, so the field here\n * steps back and says where it went.\n */\nexport function InventorySection({ id, draft, onChange }: InventorySectionProps) {\n  const stockHelp = !draft.trackStock\n    ? 'Turn on Track stock to count it.'\n    : draft.hasOptions\n      ? 'Kept per variant, under Options.'\n      : undefined;\n\n  return (\n    <FormSection title=\"Inventory\" description=\"How Orbit keeps count of what is on the shelf.\">\n      <div className=\"gap-x-ws-9 grid grid-cols-2 items-start\">\n        <FormField\n          label=\"SKU\"\n          htmlFor={`${id}-sku`}\n          helperText=\"The stock number on packing slips and invoices.\"\n        >\n          <TextInput\n            id={`${id}-sku`}\n            name=\"sku\"\n            size=\"sm\"\n            autoComplete=\"off\"\n            value={draft.sku}\n            onChange={(event) => onChange({ sku: event.target.value.toUpperCase() })}\n          />\n        </FormField>\n        <FormField label=\"Stock\" htmlFor={`${id}-stock`} helperText={stockHelp}>\n          <TextInput\n            id={`${id}-stock`}\n            name=\"stock\"\n            size=\"sm\"\n            inputMode=\"numeric\"\n            autoComplete=\"off\"\n            placeholder=\"0\"\n            disabled={Boolean(stockHelp)}\n            value={stockHelp ? '' : draft.stock}\n            onChange={(event) => onChange({ stock: event.target.value.replace(/\\D/g, '') })}\n          >\n            <TextInput.Input className=\"tabular-nums\" />\n          </TextInput>\n        </FormField>\n      </div>\n      {/* Sent with the form, so a checkbox: a switch would promise it applies at once. */}\n      <Checkbox\n        size=\"sm\"\n        label=\"Track stock\"\n        description=\"Orbit stops selling a variant once none are left.\"\n        checked={draft.trackStock}\n        onCheckedChange={(on) => onChange({ trackStock: on === true })}\n      />\n    </FormSection>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/list-preview.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/list-preview.tsx",
      "content": "'use client';\n\nimport { Card } from '@/components/ui/wideset/card/Card';\nimport { useId } from 'react';\n\nimport { CoverPlaceholder } from './cover-placeholder';\nimport { type ProductDraft, variantFields, variantsOf } from './data';\nimport { formatUsd, parseAmount } from './format';\n\n/** The price a list shows: one figure, or the lowest with \"From\" when the variants differ. */\nfunction priceOf(draft: ProductDraft) {\n  const variants = draft.hasOptions ? variantsOf(draft.options) : [];\n  const prices = (\n    variants.length > 0\n      ? variants.map((variant) => variantFields(draft, variant).price)\n      : [draft.price]\n  )\n    .map(parseAmount)\n    .filter((cents) => cents > 0);\n  if (prices.length === 0) return null;\n  const low = Math.min(...prices);\n  return {\n    label: low === Math.max(...prices) ? formatUsd(low) : `From ${formatUsd(low)}`,\n    low,\n  };\n}\n\n/**\n * The product as the catalogue will list it: the cover, the name, the line under it and the\n * price, redrawn on every keystroke. Blocks ship no images, so the cover is the same neutral\n * tile as in Media; with no photo it says so. The catalogue card is its own container, so its\n * title sits above it rather than in a second box around it.\n */\nexport function ListPreview({ draft }: { draft: ProductDraft }) {\n  const price = priceOf(draft);\n  const compareAt = parseAmount(draft.compareAt);\n  const name = draft.name.trim();\n  const cover = draft.photos[0];\n  const titleId = useId();\n\n  return (\n    <section aria-labelledby={titleId} className=\"gap-ws-9 flex flex-col\">\n      <div className=\"gap-ws-2 flex flex-col\">\n        <h2 id={titleId} className=\"typography-label-strong-md text-ws-static-strong\">\n          Preview\n        </h2>\n        <p className=\"typography-body-md text-ws-static-subtle\">How it shows in the catalogue.</p>\n      </div>\n      <Card>\n        <Card.Media ratio=\"16/9\">\n          <CoverPlaceholder cover={cover} />\n        </Card.Media>\n        <Card.Content contentClassName=\"pr-ws-6\">\n          <div className=\"gap-ws-5 flex flex-col\">\n            <div className=\"gap-ws-2 flex flex-col\">\n              <p\n                className={\n                  name\n                    ? 'typography-label-strong-md text-ws-static-strong'\n                    : 'typography-label-strong-md text-ws-static-subtle'\n                }\n              >\n                {name || 'Product name'}\n              </p>\n              {draft.summary.trim() && (\n                <p className=\"typography-body-sm text-ws-static-subtle line-clamp-2\">\n                  {draft.summary}\n                </p>\n              )}\n            </div>\n            <p className=\"gap-ws-3 flex items-baseline tabular-nums\">\n              {price ? (\n                <span className=\"typography-label-strong-md text-ws-static-strong\">\n                  {price.label}\n                </span>\n              ) : (\n                <span className=\"typography-label-md text-ws-static-subtle\">No price yet</span>\n              )}\n              {price && compareAt > price.low && (\n                <s className=\"typography-label-sm text-ws-static-subtle\">{formatUsd(compareAt)}</s>\n              )}\n            </p>\n          </div>\n        </Card.Content>\n      </Card>\n    </section>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/media-section.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/media-section.tsx",
      "content": "'use client';\n\nimport { FileUpload } from '@/components/ui/wideset/file-upload/FileUpload';\nimport { FormField } from '@/components/ui/wideset/form-field/FormField';\nimport { type DragEvent, useRef, useState } from 'react';\n\nimport type { Photo, ProductDraft } from './data';\nimport { FormSection } from './form-section';\nimport { PhotoTile } from './photo-tile';\nimport type { Errors } from './validate';\n\ntype MediaSectionProps = {\n  /** Prefix for the field ids; the drop zone is `${id}-photos`, where a failed publish lands. */\n  id: string;\n  photos: Photo[];\n  errors: Errors;\n  onChange: (patch: Partial<ProductDraft>) => void;\n};\n\n/**\n * The product's photos as a grid of square tiles, the cover first, and the drop zone as the next\n * tile, so adding one puts it where it will appear. With no file library to hand, the zone opens\n * the hidden input FileUpload renders and takes drops itself; the files are only named here.\n */\nexport function MediaSection({ id, photos, errors, onChange }: MediaSectionProps) {\n  const upload = useRef<HTMLDivElement>(null);\n  const [dragging, setDragging] = useState(false);\n  const zoneId = `${id}-photos`;\n\n  const add = (files: FileList | null) => {\n    const added = Array.from(files ?? []).filter((file) => file.type.startsWith('image/'));\n    if (added.length === 0) return;\n    const stamp = Date.now();\n    onChange({\n      photos: [...photos, ...added.map((file, i) => ({ id: `${stamp}-${i}`, name: file.name }))],\n    });\n  };\n\n  const move = (from: number, to: number) => {\n    const next = [...photos];\n    next.splice(to, 0, ...next.splice(from, 1));\n    onChange({ photos: next });\n  };\n\n  const drop = {\n    id: zoneId,\n    className: 'flex-1',\n    onDragOver: (event: DragEvent<HTMLElement>) => {\n      event.preventDefault();\n      setDragging(true);\n    },\n    onDragLeave: () => setDragging(false),\n    onDrop: (event: DragEvent<HTMLElement>) => {\n      event.preventDefault();\n      setDragging(false);\n      add(event.dataTransfer.files);\n    },\n  };\n\n  return (\n    <FormSection\n      title=\"Media\"\n      description=\"Photos for lists and the product page. The first one is the cover.\"\n    >\n      <FormField\n        label=\"Photos\"\n        required\n        helperText=\"PNG or JPG, up to 20 MB each.\"\n        errorText={errors.photos}\n      >\n        <ul aria-label=\"Photos\" className=\"gap-ws-7 grid grid-cols-[repeat(4,minmax(0,1fr))]\">\n          {photos.map((photo, index) => (\n            <PhotoTile\n              key={photo.id}\n              photo={photo}\n              index={index}\n              count={photos.length}\n              onMove={(to) => move(index, to)}\n              onRemove={() => {\n                onChange({ photos: photos.filter((p) => p.id !== photo.id) });\n                // The tile and its button go; focus waits on the drop zone instead of the page.\n                document.getElementById(zoneId)?.focus();\n              }}\n            />\n          ))}\n          <li className=\"flex min-w-0\">\n            <FileUpload\n              ref={upload}\n              className=\"aspect-square min-w-0 flex-1 self-start\"\n              labels={{ dropzone: 'Add photos', dropzoneActive: 'Drop to add' }}\n              isDragActive={dragging}\n              zoneProps={drop}\n              inputProps={{\n                accept: 'image/png,image/jpeg',\n                multiple: true,\n                onChange: (event) => {\n                  add(event.target.files);\n                  event.target.value = '';\n                },\n              }}\n              onBrowse={() => upload.current?.querySelector('input')?.click()}\n            />\n          </li>\n        </ul>\n      </FormField>\n    </FormSection>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/money-input.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/money-input.tsx",
      "content": "'use client';\n\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\n\nimport { formatAmount, parseAmount } from './format';\n\ntype MoneyInputProps = {\n  id?: string;\n  name?: string;\n  value: string;\n  onChange: (value: string) => void;\n  required?: boolean;\n  invalid?: boolean;\n  /** Names the field when no label is linked to it (a table cell). */\n  'aria-label'?: string;\n  /** Right-aligns the figure, for a column of amounts. */\n  alignEnd?: boolean;\n  className?: string;\n};\n\n/**\n * An amount in US dollars: the sign as a fixed prefix, digits only, settled into an amount when\n * the field is left (149 → 149.00), so every price on the page reads the same way.\n */\nexport function MoneyInput({\n  value,\n  onChange,\n  invalid,\n  alignEnd,\n  className,\n  ...props\n}: MoneyInputProps) {\n  return (\n    <TextInput\n      size=\"sm\"\n      inputMode=\"decimal\"\n      autoComplete=\"off\"\n      placeholder=\"0.00\"\n      variant={invalid ? 'danger' : 'primary'}\n      value={value}\n      onChange={(event) => onChange(event.target.value.replace(/[^\\d.,]/g, ''))}\n      onBlur={() => parseAmount(value) >= 0 && onChange(formatAmount(parseAmount(value)))}\n      className={className}\n      {...props}\n    >\n      <TextInput.Prefix>$</TextInput.Prefix>\n      <TextInput.Input className={alignEnd ? 'text-right tabular-nums' : 'tabular-nums'} />\n    </TextInput>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/option-row.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/option-row.tsx",
      "content": "'use client';\n\n// TODO(custom): an option's values as removable chips with a field to add more; Wideset has no chip or tag input.\nimport { RiDeleteBinLine } from '@remixicon/react';\nimport { Chip } from '@/components/ui/wideset/chip/Chip';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\nimport { useState } from 'react';\n\nimport type { ProductOption } from './data';\n\ntype OptionRowProps = {\n  /** The name field's id, so a row just added can be focused. */\n  nameId: string;\n  option: ProductOption;\n  onChange: (option: ProductOption) => void;\n  onRemove: () => void;\n};\n\n/** The grid an option row and the labels above the rows share. */\nexport const OPTION_GRID = 'gap-ws-7 grid grid-cols-[10rem_minmax(0,1fr)_auto]';\n\n/**\n * One option: its name, its values as chips, and a field that adds a value on Enter or when it is\n * left. A chip removes its value; Backspace in the empty field takes the last one, as in any\n * tag field. A value already there is not added twice.\n */\nexport function OptionRow({ nameId, option, onChange, onRemove }: OptionRowProps) {\n  const [text, setText] = useState('');\n  const label = option.name.trim() || 'option';\n\n  const add = () => {\n    const value = text.trim();\n    setText('');\n    if (value && !option.values.includes(value))\n      onChange({ ...option, values: [...option.values, value] });\n  };\n  const remove = (value: string) =>\n    onChange({ ...option, values: option.values.filter((v) => v !== value) });\n\n  return (\n    <div role=\"group\" aria-label={`Option: ${label}`} className={`${OPTION_GRID} items-start`}>\n      <TextInput\n        id={nameId}\n        size=\"sm\"\n        aria-label=\"Option name\"\n        placeholder=\"Colour\"\n        autoComplete=\"off\"\n        value={option.name}\n        onChange={(event) => onChange({ ...option, name: event.target.value })}\n      />\n      <div className=\"gap-ws-3 flex min-w-0 flex-wrap items-center\">\n        {option.values.map((value) => (\n          <Chip key={value} variant=\"secondary\">\n            <Chip.Label>{value}</Chip.Label>\n            <Chip.IconButton\n              aria-label={`Remove ${value} from ${label}`}\n              onClick={() => remove(value)}\n            />\n          </Chip>\n        ))}\n        <TextInput\n          size=\"sm\"\n          aria-label={`Add a value to ${label}`}\n          placeholder=\"Add value\"\n          autoComplete=\"off\"\n          className=\"w-[8rem]\"\n          value={text}\n          onChange={(event) => setText(event.target.value)}\n          onBlur={add}\n          onKeyDown={(event) => {\n            if (event.key === 'Enter') {\n              // Enter adds the value; it must not submit the form around it.\n              event.preventDefault();\n              add();\n            } else if (event.key === 'Backspace' && !text && option.values.length > 0) {\n              remove(option.values[option.values.length - 1]);\n            }\n          }}\n        />\n      </div>\n      <IconButton\n        icon={RiDeleteBinLine}\n        size=\"sm\"\n        variant=\"secondary\"\n        preset=\"ghost\"\n        aria-label={`Remove the ${label} option`}\n        onClick={onRemove}\n      />\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/options-section.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/options-section.tsx",
      "content": "'use client';\n\nimport { RiAddLine } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { Checkbox } from '@/components/ui/wideset/checkbox/Checkbox';\n\nimport { OPTION_LIMIT, type ProductDraft, variantsOf } from './data';\nimport { FormSection } from './form-section';\nimport { OPTION_GRID, OptionRow } from './option-row';\nimport { VariantsTable } from './variants-table';\n\ntype OptionsSectionProps = {\n  id: string;\n  draft: ProductDraft;\n  onChange: (patch: Partial<ProductDraft>) => void;\n};\n\n/** A quiet label over a column of the option rows; the fields carry their own names. */\nconst COLUMN_LABEL = 'typography-label-strong-sm text-ws-static-strong';\n\n/**\n * Sizes, colours and other choices. The checkbox reveals them; each option is a row of values, and\n * the variants they make follow underneath, each with its price and stock. Up to three options,\n * as most catalogues allow.\n */\nexport function OptionsSection({ id, draft, onChange }: OptionsSectionProps) {\n  const variants = variantsOf(draft.options);\n  const nameId = (optionId: string) => `${id}-option-${optionId}`;\n\n  const addOption = () => {\n    const option = { id: String(Date.now()), name: '', values: [] };\n    onChange({ options: [...draft.options, option] });\n    // The row renders on the next frame; start in its name.\n    requestAnimationFrame(() => document.getElementById(nameId(option.id))?.focus());\n  };\n\n  return (\n    <FormSection\n      title=\"Options\"\n      description=\"Sizes, colours or other choices a customer picks from.\"\n    >\n      <Checkbox\n        size=\"sm\"\n        label=\"This product has options\"\n        description=\"Each combination of values becomes a variant with its own price and stock.\"\n        checked={draft.hasOptions}\n        onCheckedChange={(on) => {\n          const hasOptions = on === true;\n          onChange(\n            hasOptions && draft.options.length === 0\n              ? { hasOptions, options: [{ id: 'size', name: 'Size', values: [] }] }\n              : { hasOptions },\n          );\n        }}\n      />\n\n      {draft.hasOptions && (\n        <>\n          <div className=\"gap-ws-7 flex flex-col\">\n            <div aria-hidden=\"true\" className={OPTION_GRID}>\n              <span className={COLUMN_LABEL}>Option</span>\n              <span className={COLUMN_LABEL}>Values</span>\n            </div>\n            {draft.options.map((option) => (\n              <OptionRow\n                key={option.id}\n                nameId={nameId(option.id)}\n                option={option}\n                onChange={(next) =>\n                  onChange({ options: draft.options.map((o) => (o.id === next.id ? next : o)) })\n                }\n                onRemove={() =>\n                  onChange({ options: draft.options.filter((o) => o.id !== option.id) })\n                }\n              />\n            ))}\n            {draft.options.length < OPTION_LIMIT && (\n              <div>\n                <Button size=\"sm\" variant=\"secondary\" preset=\"border\" onClick={addOption}>\n                  <Button.Icon icon={RiAddLine} />\n                  Add another option\n                </Button>\n              </div>\n            )}\n          </div>\n\n          {variants.length > 0 && (\n            <VariantsTable\n              draft={draft}\n              variants={variants}\n              onChange={(variant, fields) =>\n                onChange({ variants: { ...draft.variants, [variant.key]: fields } })\n              }\n            />\n          )}\n        </>\n      )}\n    </FormSection>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/page-header.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/page-header.tsx",
      "content": "'use client';\n\n// TODO(custom): page header (title with its status, a line of description, the actions on the right); no PageHeader in Wideset.\nimport { StatusBadge } from '@/components/ui/wideset/status-badge/StatusBadge';\nimport type { ReactNode } from 'react';\n\nimport type { Status } from './data';\n\ntype PageHeaderProps = {\n  title: string;\n  /** The saved product's state; a product never saved has none. */\n  status?: Status;\n  description: string;\n  /** The page's buttons, the filled one last; left out when they sit in a bar at the foot. */\n  children?: ReactNode;\n};\n\n/**\n * The page's title, one line saying where the product stands, and what to do with it on the\n * right. Once saved, the title is the product's name and its state sits beside it, coloured by\n * meaning: Active is on sale, so positive; a draft has nothing to signal, so neutral.\n */\nexport function PageHeader({ title, status, description, children }: PageHeaderProps) {\n  return (\n    <header className=\"gap-ws-12 flex flex-wrap items-center justify-between\">\n      <div className=\"gap-ws-2 flex min-w-0 flex-col\">\n        <div className=\"gap-ws-5 flex min-w-0 items-center\">\n          <h1 className=\"typography-title-sm text-ws-static-strong truncate\">{title}</h1>\n          {status && (\n            <StatusBadge size=\"lg\" color={status === 'active' ? 'positive' : 'neutral'}>\n              {status === 'active' ? 'Active' : 'Draft'}\n            </StatusBadge>\n          )}\n        </div>\n        <p className=\"typography-body-md text-ws-static-subtle\">{description}</p>\n      </div>\n      {children && <div className=\"gap-ws-5 flex items-center\">{children}</div>}\n    </header>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/people.assets.ts",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/people.assets.ts",
      "content": "// Portraits of the sample people as small JPEG data URLs (a block ships only .ts and .tsx).\n// Exported from the Wideset Core Figma file by people.cjs: do not edit by hand.\n\n/** A person’s photo by name. People who are not here show their initials. */\nexport const PHOTOS: Record<string, string | undefined> = {\n  'Maya Okafor':\n    'data:image/jpeg;base64,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',\n};\n"
    },
    {
      "path": "src/blocks/product-form/person-avatar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/person-avatar.tsx",
      "content": "'use client';\n\nimport type { AvatarProps } from '@/components/ui/wideset/avatar/Avatar.types';\nimport { Avatar } from '@/components/ui/wideset/avatar/Avatar';\n\nimport { PHOTOS } from './people.assets';\n\ntype PersonAvatarProps = Pick<\n  AvatarProps,\n  'size' | 'shape' | 'status' | 'color' | 'className' | 'title' | 'aria-hidden' | 'aria-label'\n> & {\n  /** The person's full name: the key their photo is filed under. */\n  name: string;\n  initials: string;\n  /** Leave empty beside the person's name; pass the name where the avatar stands alone. */\n  alt?: string;\n};\n\n/**\n * A person's avatar: their photo when the sample people have one, otherwise their initials in\n * their colour. A real product mixes the two, so every place the block draws a person asks here\n * and the choice is made once. The initials stay as the fallback if the image fails to load.\n */\nexport function PersonAvatar({ name, initials, color, alt = '', ...props }: PersonAvatarProps) {\n  const photo = PHOTOS[name];\n  return photo ? (\n    <Avatar src={photo} alt={alt} initials={initials} {...props} />\n  ) : (\n    <Avatar initials={initials} color={color} {...props} />\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/photo-tile.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/photo-tile.tsx",
      "content": "'use client';\n\n// TODO(custom): a photo in a media grid (preview, cover mark, remove and reorder); Wideset has no MediaTile or image grid.\nimport { RiArrowLeftSLine, RiArrowRightSLine, RiCloseLine, RiImageLine } from '@remixicon/react';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { Tag } from '@/components/ui/wideset/tag/Tag';\n\nimport type { Photo } from './data';\n\ntype PhotoTileProps = {\n  photo: Photo;\n  /** Its place in the grid, from 0; the first photo is the cover. */\n  index: number;\n  count: number;\n  onMove: (to: number) => void;\n  onRemove: () => void;\n};\n\n/**\n * One added photo. Blocks ship no images, so the picture is a neutral tile with an image icon;\n * in a product it is the photo, cropped square. The cover carries its mark on the picture,\n * Remove sits in the other corner, and the arrows under it move the photo one place, which is\n * how the cover changes without dragging.\n */\nexport function PhotoTile({ photo, index, count, onMove, onRemove }: PhotoTileProps) {\n  return (\n    <li className=\"gap-ws-3 flex min-w-0 flex-col\">\n      <div className=\"bg-ws-static-alpha-subtle rounded-ws-container-md relative flex aspect-square items-center justify-center\">\n        <RiImageLine aria-hidden=\"true\" className=\"size-ws-12 text-ws-static-subtle\" />\n        {index === 0 && (\n          <Tag size=\"sm\" color=\"secondary\" className=\"top-ws-5 left-ws-5 absolute\">\n            Cover\n          </Tag>\n        )}\n        <IconButton\n          icon={RiCloseLine}\n          size=\"xs\"\n          variant=\"secondary\"\n          preset=\"border\"\n          aria-label={`Remove ${photo.name}`}\n          onClick={onRemove}\n          className=\"top-ws-5 right-ws-5 absolute\"\n        />\n      </div>\n      <div className=\"gap-ws-2 flex items-center\">\n        <span className=\"typography-caption-md text-ws-static-subtle min-w-0 flex-1 truncate\">\n          {photo.name}\n        </span>\n        <IconButton\n          icon={RiArrowLeftSLine}\n          size=\"xs\"\n          variant=\"secondary\"\n          preset=\"ghost\"\n          aria-label={index === 1 ? `Make ${photo.name} the cover` : `Move ${photo.name} earlier`}\n          disabled={index === 0}\n          onClick={() => onMove(index - 1)}\n        />\n        <IconButton\n          icon={RiArrowRightSLine}\n          size=\"xs\"\n          variant=\"secondary\"\n          preset=\"ghost\"\n          aria-label={`Move ${photo.name} later`}\n          disabled={index === count - 1}\n          onClick={() => onMove(index + 1)}\n        />\n      </div>\n    </li>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/pricing-section.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/pricing-section.tsx",
      "content": "'use client';\n\nimport { FormField } from '@/components/ui/wideset/form-field/FormField';\nimport { Select } from '@/components/ui/wideset/select/Select';\n\nimport { type ProductDraft, taxClasses } from './data';\nimport { FormSection } from './form-section';\nimport { formatPercent, formatUsd, parseAmount } from './format';\nimport { MoneyInput } from './money-input';\nimport type { Errors } from './validate';\n\ntype PricingSectionProps = {\n  id: string;\n  draft: ProductDraft;\n  errors: Errors;\n  onChange: (patch: Partial<ProductDraft>) => void;\n};\n\n/** What the margin line says: the profit and the margin while both figures are in, a hint until. */\nfunction marginLine(priceText: string, costText: string) {\n  const price = parseAmount(priceText);\n  const cost = parseAmount(costText);\n  if (!(price > 0) || !(cost >= 0)) return 'Add a price and a cost to see the margin.';\n  const profit = price - cost;\n  return `${formatUsd(profit)} profit on each sale, a ${formatPercent(profit / price)} margin.`;\n}\n\n/**\n * What it sells for and what it costs: the price with an optional earlier price to show a\n * discount, the cost customers never see, and the tax a sale carries. The margin follows the\n * price and the cost as they are typed, in one quiet line.\n */\nexport function PricingSection({ id, draft, errors, onChange }: PricingSectionProps) {\n  return (\n    <FormSection\n      title=\"Pricing\"\n      description=\"What customers pay, and what each sale leaves Lumen Studio.\"\n    >\n      <div className=\"gap-x-ws-9 gap-y-ws-11 grid grid-cols-2 items-start\">\n        <FormField label=\"Price\" htmlFor={`${id}-price`} required errorText={errors.price}>\n          <MoneyInput\n            id={`${id}-price`}\n            name=\"price\"\n            required\n            invalid={Boolean(errors.price)}\n            value={draft.price}\n            onChange={(price) => onChange({ price })}\n          />\n        </FormField>\n        <FormField\n          label=\"Compare-at price\"\n          htmlFor={`${id}-compare-at`}\n          helperText=\"The price before a discount, shown struck through.\"\n        >\n          <MoneyInput\n            id={`${id}-compare-at`}\n            name=\"compareAt\"\n            value={draft.compareAt}\n            onChange={(compareAt) => onChange({ compareAt })}\n          />\n        </FormField>\n        <FormField\n          label=\"Cost per item\"\n          htmlFor={`${id}-cost`}\n          helperText=\"Lumen Studio’s cost. Customers don’t see it.\"\n        >\n          <MoneyInput\n            id={`${id}-cost`}\n            name=\"cost\"\n            value={draft.cost}\n            onChange={(cost) => onChange({ cost })}\n          />\n        </FormField>\n        <FormField label=\"Tax class\" htmlFor={`${id}-tax`}>\n          <Select\n            id={`${id}-tax`}\n            name=\"taxClass\"\n            size=\"sm\"\n            preset=\"border\"\n            className=\"w-full\"\n            options={taxClasses}\n            value={draft.taxClass}\n            onValueChange={(taxClass) => onChange({ taxClass })}\n          />\n        </FormField>\n      </div>\n      <p aria-live=\"polite\" className=\"typography-body-md text-ws-static-base tabular-nums\">\n        {marginLine(draft.price, draft.cost)}\n      </p>\n    </FormSection>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/sales-channels.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/sales-channels.tsx",
      "content": "'use client';\n\nimport { Checkbox } from '@/components/ui/wideset/checkbox/Checkbox';\nimport { CheckboxGroup } from '@/components/ui/wideset/checkbox/CheckboxGroup';\n\nimport { channels } from './data';\nimport { FormSection } from './form-section';\n\ntype SalesChannelsProps = {\n  selected: string[];\n  onChange: (selected: string[]) => void;\n};\n\n/** Where the product can be bought once it is on sale: one checkbox a channel. */\nexport function SalesChannels({ selected, onChange }: SalesChannelsProps) {\n  return (\n    <FormSection title=\"Visibility\" description=\"Where customers can buy it.\">\n      <CheckboxGroup aria-label=\"Sales channels\">\n        {channels.map((channel) => (\n          <Checkbox\n            key={channel.id}\n            size=\"sm\"\n            label={channel.label}\n            checked={selected.includes(channel.id)}\n            onCheckedChange={(on) =>\n              onChange(\n                on === true\n                  ? [...selected, channel.id]\n                  : selected.filter((id) => id !== channel.id),\n              )\n            }\n          />\n        ))}\n      </CheckboxGroup>\n    </FormSection>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/save-bar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/save-bar.tsx",
      "content": "'use client';\n\n// TODO(custom): save bar along the card's foot (Cancel, Save draft, Publish); ActionBar is for selections only.\nimport { cn } from '@/lib/wideset/utils';\nimport type { ReactNode } from 'react';\n\n/**\n * The centred layout's actions: a bar pinned to the card's foot, under the scrolling form, so\n * Publish stays in view however far down the form is filled. It runs on the form's column, so\n * its buttons end where the sections do. Copied from account-settings, always shown here.\n */\nexport function SaveBar({ column, children }: { column: string; children: ReactNode }) {\n  return (\n    <div className=\"border-ws-static-base py-ws-7 shrink-0 border-t\">\n      <div className={cn(column, 'gap-ws-5 flex items-center justify-end')}>{children}</div>\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/sidebar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/sidebar.tsx",
      "content": "'use client';\n\n// TODO(custom): workspace switcher and account menu are composed by hand.\nimport {\n  RiAddLine,\n  RiArrowDownSLine,\n  RiLogoutBoxRLine,\n  RiSearchLine,\n  RiSettingsLine,\n} from '@remixicon/react';\nimport { Divider } from '@/components/ui/wideset/divider/Divider';\nimport { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { ListItem } from '@/components/ui/wideset/list-item/ListItem';\nimport { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';\nimport { type SidebarProps } from '@/components/ui/wideset/sidebar/Sidebar.types';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\nimport { useState } from 'react';\n\nimport { BrandMark } from './brand-mark';\nimport {\n  account,\n  helpLink,\n  mainLinks,\n  type NavLink,\n  product,\n  settingsLinks,\n  workspace,\n} from './data';\nimport { PersonAvatar } from './person-avatar';\n\n/**\n * The workspace sidebar: switcher, search, the app's pages, settings and the signed-in account.\n * Its toggle sits in the page bar, so the screen holds `collapsed` and passes it down; collapsed,\n * it keeps the mark, the page icons and the avatar.\n */\nexport function ProductFormSidebar(\n  props: Pick<SidebarProps, 'id' | 'collapsed' | 'onCollapsedChange'>,\n) {\n  const [active, setActive] = useState('catalogue');\n\n  const link = ({ id, label, icon, activeIcon }: NavLink) => (\n    <Sidebar.Item\n      key={id}\n      href={`#${id}`}\n      icon={active === id ? (activeIcon ?? icon) : icon}\n      label={label}\n      active={active === id}\n      onClick={() => setActive(id)}\n    />\n  );\n\n  const nav = (\n    <nav aria-label=\"Workspace\" className=\"gap-ws-9 flex flex-col\">\n      <div className=\"flex flex-col\">{mainLinks.map(link)}</div>\n      <Divider weight=\"thin\" />\n      <div role=\"group\" aria-labelledby=\"sidebar-settings\" className=\"gap-ws-2 flex flex-col\">\n        <Sidebar.SectionHeader id=\"sidebar-settings\">Settings</Sidebar.SectionHeader>\n        {settingsLinks.map(link)}\n      </div>\n    </nav>\n  );\n\n  return (\n    <Sidebar {...props}>\n      <Sidebar.Header>\n        <Sidebar.Expanded>\n          <div className=\"gap-ws-9 flex flex-col\">\n            <div className=\"gap-ws-7 pt-ws-3 pb-ws-7 flex items-center\">\n              <BrandMark className=\"size-ws-15\" />\n              <div className=\"flex min-w-0 flex-1 flex-col\">\n                <span className=\"typography-label-strong-sm text-ws-static-strong truncate\">\n                  {workspace.name}\n                </span>\n                <span className=\"typography-caption-md text-ws-static-subtle truncate\">\n                  {product.name}\n                </span>\n              </div>\n              <DropdownMenu>\n                <DropdownMenu.Trigger asChild>\n                  <IconButton\n                    icon={RiArrowDownSLine}\n                    variant=\"secondary\"\n                    preset=\"ghost\"\n                    size=\"xs\"\n                    aria-label=\"Switch workspace\"\n                    className=\"mr-ws-3\"\n                  />\n                </DropdownMenu.Trigger>\n                <DropdownMenu.Content className=\"ws-block-utility\" align=\"end\">\n                  <DropdownMenu.Item data-state=\"checked\">\n                    <ListItem.Content>\n                      <ListItem.Label>{workspace.name}</ListItem.Label>\n                    </ListItem.Content>\n                  </DropdownMenu.Item>\n                  <DropdownMenu.Separator />\n                  <DropdownMenu.Item>\n                    <ListItem.Prefix>\n                      <RiAddLine className=\"size-ws-9\" />\n                    </ListItem.Prefix>\n                    <ListItem.Content>\n                      <ListItem.Label>New workspace</ListItem.Label>\n                    </ListItem.Content>\n                  </DropdownMenu.Item>\n                </DropdownMenu.Content>\n              </DropdownMenu>\n            </div>\n            <TextInput size=\"sm\">\n              <TextInput.Prefix inner>\n                <TextInput.Icon icon={RiSearchLine} />\n              </TextInput.Prefix>\n              <TextInput.Input type=\"search\" placeholder=\"Search\" aria-label=\"Search\" />\n            </TextInput>\n          </div>\n        </Sidebar.Expanded>\n        <Sidebar.Collapsed>\n          <div className=\"pt-ws-3 pb-ws-7 flex justify-center\">\n            <BrandMark className=\"size-ws-15\" />\n          </div>\n        </Sidebar.Collapsed>\n      </Sidebar.Header>\n\n      {/* A section draws only the slot for the state it is in, so the pages go in both. */}\n      <Sidebar.Section scrollable>{nav}</Sidebar.Section>\n\n      <Sidebar.Footer>\n        <div className=\"gap-ws-9 flex flex-col\">\n          <div className=\"flex flex-col\">{link(helpLink)}</div>\n          {/* On the grey ground the line keeps the nav's inset: run edge to edge, it would stop\n              short of the page and read as broken. */}\n          <div className=\"border-ws-static-base pt-ws-5 border-t\">\n            <Sidebar.Expanded>\n              <DropdownMenu>\n                <DropdownMenu.Trigger asChild>\n                  <button\n                    type=\"button\"\n                    className=\"gap-ws-5 px-ws-5 py-ws-3 rounded-ws-control-lg hover:bg-ws-dynamic-tertiary-alpha-strong-default focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default flex w-full items-center text-left\"\n                  >\n                    <PersonAvatar name={account.name} initials={account.initials} color=\"orange\" />\n                    <span className=\"flex min-w-0 flex-1 flex-col\">\n                      <span className=\"typography-label-strong-sm text-ws-static-base truncate\">\n                        {account.name}\n                      </span>\n                      <span className=\"typography-caption-md text-ws-static-subtle truncate\">\n                        {account.email}\n                      </span>\n                    </span>\n                    <RiArrowDownSLine\n                      aria-hidden=\"true\"\n                      className=\"size-ws-9 text-ws-static-strong\"\n                    />\n                  </button>\n                </DropdownMenu.Trigger>\n                <DropdownMenu.Content side=\"top\" align=\"start\" className=\"ws-block-utility w-[14rem]\">\n                  <DropdownMenu.Item>\n                    <ListItem.Prefix>\n                      <RiSettingsLine className=\"size-ws-9\" />\n                    </ListItem.Prefix>\n                    <ListItem.Content>\n                      <ListItem.Label>Account settings</ListItem.Label>\n                    </ListItem.Content>\n                  </DropdownMenu.Item>\n                  <DropdownMenu.Separator />\n                  <DropdownMenu.Item variant=\"danger\">\n                    <ListItem.Prefix>\n                      <RiLogoutBoxRLine className=\"size-ws-9\" />\n                    </ListItem.Prefix>\n                    <ListItem.Content>\n                      <ListItem.Label>Log out</ListItem.Label>\n                    </ListItem.Content>\n                  </DropdownMenu.Item>\n                </DropdownMenu.Content>\n              </DropdownMenu>\n            </Sidebar.Expanded>\n            <Sidebar.Collapsed>\n              <div className=\"flex justify-center\">\n                <PersonAvatar\n                  name={account.name}\n                  initials={account.initials}\n                  color=\"orange\"\n                  title={account.name}\n                  alt={account.name}\n                />\n              </div>\n            </Sidebar.Collapsed>\n          </div>\n        </div>\n      </Sidebar.Footer>\n    </Sidebar>\n  );\n}\n"
    },
    {
      "path": "src/blocks/product-form/validate.ts",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/validate.ts",
      "content": "import { type ProductDraft, variantFields, variantsOf } from './data';\nimport { parseAmount } from './format';\n\n/** The fields a save can stop at, in the order they sit on the page. */\nexport type ErrorField = 'name' | 'photos' | 'price';\nexport type Errors = Partial<Record<ErrorField, string>>;\n\n/** What each missing thing is called in the summary at the top. */\nexport const MISSING: Record<ErrorField, string> = {\n  name: 'a name',\n  photos: 'a photo',\n  price: 'a price',\n};\n\n/**\n * What stops a save. A draft only needs a name, so it can be found in the catalogue again;\n * publishing also needs a price (on every variant, when there are options) and a photo for the\n * cover, since that is what a customer sees first.\n */\nexport function validate(draft: ProductDraft, publishing: boolean): Errors {\n  const errors: Errors = {};\n  if (!draft.name.trim()) errors.name = 'Enter the product’s name.';\n  if (!publishing) return errors;\n\n  if (draft.photos.length === 0) errors.photos = 'Add at least one photo for the cover.';\n\n  const prices = draft.hasOptions\n    ? variantsOf(draft.options).map((variant) => variantFields(draft, variant).price)\n    : [draft.price];\n  if (!(parseAmount(draft.price) > 0)) errors.price = 'Enter a price above $0.00.';\n  else if (prices.some((price) => !(parseAmount(price) > 0)))\n    errors.price = 'Give every variant a price above $0.00, under Options.';\n  return errors;\n}\n"
    },
    {
      "path": "src/blocks/product-form/variants-table.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/product-form/variants-table.tsx",
      "content": "'use client';\n\nimport { Table } from '@/components/ui/wideset/table/Table';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\n\nimport { type ProductDraft, type Variant, type VariantFields, variantFields } from './data';\nimport { MoneyInput } from './money-input';\n\ntype VariantsTableProps = {\n  draft: ProductDraft;\n  variants: Variant[];\n  onChange: (variant: Variant, fields: VariantFields) => void;\n};\n\n/**\n * Every combination the options make, one row each, with its own price and, while stock is\n * tracked, its own count. A new variant starts at the product's price. The figures are fields\n * right-aligned in their column, so they read as numbers, not as a form.\n */\nexport function VariantsTable({ draft, variants, onChange }: VariantsTableProps) {\n  return (\n    <Table size=\"sm\" aria-label=\"Variants\" className=\"w-full\">\n      <Table.Head>\n        <Table.Row>\n          <Table.Header flushMargin className=\"w-full\">\n            Variant\n          </Table.Header>\n          <Table.Header align=\"right\">Price</Table.Header>\n          {draft.trackStock && (\n            <Table.Header align=\"right\" flushMargin>\n              Stock\n            </Table.Header>\n          )}\n        </Table.Row>\n      </Table.Head>\n      <Table.Body>\n        {variants.map((variant) => {\n          const { name } = variant;\n          const fields = variantFields(draft, variant);\n          return (\n            <Table.Row key={variant.key}>\n              <Table.Cell flushMargin className=\"text-ws-static-strong\">\n                {name}\n              </Table.Cell>\n              <Table.Cell align=\"right\" flushMargin={!draft.trackStock}>\n                <MoneyInput\n                  aria-label={`Price of ${name}`}\n                  alignEnd\n                  className=\"w-[8rem]\"\n                  value={fields.price}\n                  onChange={(price) => onChange(variant, { ...fields, price })}\n                />\n              </Table.Cell>\n              {draft.trackStock && (\n                <Table.Cell align=\"right\" flushMargin>\n                  <TextInput\n                    size=\"sm\"\n                    inputMode=\"numeric\"\n                    autoComplete=\"off\"\n                    placeholder=\"0\"\n                    aria-label={`Stock of ${name}`}\n                    className=\"w-[6rem]\"\n                    value={fields.stock}\n                    onChange={(event) =>\n                      onChange(variant, { ...fields, stock: event.target.value.replace(/\\D/g, '') })\n                    }\n                  >\n                    <TextInput.Input className=\"text-right tabular-nums\" />\n                  </TextInput>\n                </Table.Cell>\n              )}\n            </Table.Row>\n          );\n        })}\n      </Table.Body>\n    </Table>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "commit": "a734f9f0"
  }
}
