{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "core-product-card",
  "type": "registry:lib",
  "title": "core/product-card",
  "description": "Framework-free behaviour shared by the ui-* components (product-card); no DOM, no lit. Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/core/product-card.ts",
      "type": "registry:lib",
      "target": "components/ui/core/product-card.ts",
      "content": "/**\n * Carbon for IBM Products `ProductiveCard` / `ExpressiveCard` (both built on its legacy `Card`): which part of the card\n * is clickable, where the action icons and the primary / secondary buttons go and what kind of button each is.\n * Read from `@carbon/ibm-products` 2.100 `Card.js`, `CardHeader.js` and `CardFooter.js`.\n */\n\n/** Which zone of a productive card is clickable (Carbon for IBM Products `clickZone`): the card, header + body, the body. */\nexport type ProductCardClickZone = 'one' | 'two' | 'three';\nexport type ProductCardPlacement = 'top' | 'bottom';\nexport type ProductCardTitleSize = 'default' | 'large';\nexport type ProductCardMediaPosition = 'top' | 'left';\n/** The element a clickable card makes clickable: the whole card, the header with the body, or the body. */\nexport type ProductCardZone = 'card' | 'header-body' | 'body';\nexport type ProductCardPrimaryKind = 'primary' | 'ghost';\nexport type ProductCardSecondaryKind = 'secondary' | 'ghost';\n\nexport interface ProductCardInput {\n    /** ProductiveCard (true) or ExpressiveCard (false). */\n    productive: boolean;\n    /** Something listens for the card's click (Carbon: an `onClick` or `onKeyDown` prop). */\n    clickable: boolean;\n    clickZone: ProductCardClickZone;\n    actionsPlacement: ProductCardPlacement;\n    hasActionIcons: boolean;\n    hasOverflowActions: boolean;\n    hasPrimaryButton: boolean;\n    primaryButtonPlacement: ProductCardPlacement;\n    primaryButtonKind: ProductCardPrimaryKind;\n    hasSecondaryButton: boolean;\n    secondaryButtonPlacement: ProductCardPlacement;\n    secondaryButtonKind: ProductCardSecondaryKind;\n}\n\nexport interface ProductCardLayout {\n    /** The clickable element, or null when nothing is. */\n    zone: ProductCardZone | null;\n    /** The overflow menu replaces the action icons (Carbon: `overflowActions` win over `actionIcons`). */\n    overflow: boolean;\n    /** The actions box (icons or overflow menu, and the top buttons) in the header. */\n    headerActions: boolean;\n    /** The actions box (icons or overflow menu) in the footer. */\n    footerActions: boolean;\n    /** Size of the action icon buttons and the overflow menu: productive sm at the top, md at the bottom; expressive sm. */\n    iconSize: 'sm' | 'md';\n    /** Where the overflow menu opens: below its button at the top, above it at the bottom. */\n    overflowPlacement: 'bottom-end' | 'top-end';\n    /** Ghost sm buttons in the header's actions box. */\n    headerPrimary: boolean;\n    headerSecondary: boolean;\n    /** md buttons at the start of the footer. */\n    footerPrimary: boolean;\n    footerSecondary: boolean;\n    footerPrimaryKind: ProductCardPrimaryKind;\n    footerSecondaryKind: ProductCardSecondaryKind;\n    /** The footer is there (Carbon `hasBottomBar`). */\n    footer: boolean;\n    /** Carbon `__footer-no-button`: a productive footer then puts its actions at the end instead of spreading out. */\n    footerNoButton: boolean;\n}\n\n/**\n * Carbon `Card`: an expressive card is clickable as a whole; a productive card in its `clickZone` (one: the card,\n * two: the header with the body, three: the body).\n */\nexport function productCardZone(productive: boolean, clickable: boolean, clickZone: ProductCardClickZone): ProductCardZone | null {\n    if (!clickable) return null;\n    if (!productive || clickZone === 'one') return 'card';\n    return clickZone === 'two' ? 'header-body' : 'body';\n}\n\n/**\n * Carbon `Card`'s layout decisions, as its source has them (quirks included): the secondary button only goes to the\n * top next to other top actions, and a secondary button at the top still makes the footer (empty) appear.\n */\nexport function productCardLayout(input: ProductCardInput): ProductCardLayout {\n    const overflow = input.productive && input.hasOverflowActions;\n    const primaryTop = input.hasPrimaryButton && input.primaryButtonPlacement === 'top';\n    const hasActions = input.hasActionIcons || overflow || primaryTop;\n    const top = input.actionsPlacement === 'top';\n    const headerActions = hasActions && top;\n    const footerActions = hasActions && !top;\n    const footerButton = input.hasSecondaryButton || (input.hasPrimaryButton && input.primaryButtonPlacement === 'bottom');\n    return {\n        zone: productCardZone(input.productive, input.clickable, input.clickZone),\n        overflow,\n        headerActions,\n        footerActions,\n        iconSize: input.productive && !top ? 'md' : 'sm',\n        overflowPlacement: top ? 'bottom-end' : 'top-end',\n        headerPrimary: headerActions && primaryTop,\n        headerSecondary: headerActions && input.hasSecondaryButton && input.secondaryButtonPlacement === 'top',\n        footerPrimary: input.hasPrimaryButton && input.primaryButtonPlacement === 'bottom',\n        footerSecondary: input.hasSecondaryButton && input.secondaryButtonPlacement === 'bottom',\n        footerPrimaryKind: input.productive ? 'ghost' : input.primaryButtonKind,\n        footerSecondaryKind: input.productive ? 'ghost' : input.secondaryButtonKind,\n        footer: footerActions || footerButton,\n        footerNoButton: !footerButton,\n    };\n}\n\nexport interface ProductCardHeaderInput {\n    hasLabel: boolean;\n    hasTitle: boolean;\n    hasDescription: boolean;\n    titleSize: ProductCardTitleSize;\n}\n\n/** Carbon `CardHeader`'s classes: label only (less space below), with a label, a large title. */\nexport function productCardHeader(input: ProductCardHeaderInput) {\n    return {\n        labelOnly: input.hasLabel && !input.hasTitle && !input.hasDescription,\n        hasLabel: input.hasLabel,\n        large: input.titleSize === 'large',\n        /** Carbon `--large-tile-or-label`: a decorator then keeps more room at the end. */\n        largeOrLabel: input.hasTitle && (input.hasLabel || input.titleSize === 'large'),\n    };\n}\n\n/** An attribute value or the default (Carbon's prop types are enums; anything else falls back to the default). */\nexport function productCardEnum<T extends string>(value: string, allowed: readonly T[], fallback: T): T {\n    return (allowed as readonly string[]).includes(value) ? (value as T) : fallback;\n}\n"
    }
  ]
}
