{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"badge-group","title":"Badge Group","description":"Join a small badge and a message in one pill, such as a release note or a status line above a heading. Search terms: announcement badge, release note badge, new feature badge, notice.","dependencies":["@phosphor-icons/react@2.1.10"],"registryDependencies":["@siteplane/base","@siteplane/badge"],"files":[{"path":"packages/ui/src/components/badge-group/badge-group.tsx","content":"\"use client\";\n\nimport { ArrowRightIcon } from \"@phosphor-icons/react/dist/ssr\";\nimport * as React from \"react\";\n\nimport { Badge, BadgeDot, type BadgeProps, type BadgeVariant } from \"../badge\";\n\nimport \"./badge-group.css\";\n\n/**\n * The tint of the group, by the Badge variant that draws it: `secondary` is\n * the neutral one (gray), `info` the accent tint (the brand),\n * `success`, `warning` and `error` the status tints, and `slate`, `sky`,\n * `blue`, `indigo`, `purple`, `pink` and `orange` the colour tints. In the\n * modern appearance it names the colour of the dot.\n */\nexport type BadgeGroupVariant = Extract<\n  BadgeVariant,\n  | \"secondary\"\n  | \"info\"\n  | \"success\"\n  | \"warning\"\n  | \"error\"\n  | \"slate\"\n  | \"sky\"\n  | \"blue\"\n  | \"indigo\"\n  | \"purple\"\n  | \"pink\"\n  | \"orange\"\n>;\n\n/**\n * `light` tints the whole pill and sets the addon on it as a white pill of its\n * own. `modern` is a white, hairline group whose addon is a white badge with a\n * dot in the variant's colour.\n */\nexport type BadgeGroupAppearance = \"light\" | \"modern\";\n\n/**\n * `md` is a 30 px group with 12 px type around a 22 px addon, `lg` a 32 px\n * group with 14 px type around a 24 px addon. The addon\n * is the Badge at `sm` and `md`.\n */\nexport type BadgeGroupSize = \"md\" | \"lg\";\n\n/** Where the addon stands: before the message, or after it. */\nexport type BadgeGroupAddonPosition = \"start\" | \"end\";\n\nexport interface BadgeGroupProps extends Omit<\n  BadgeProps,\n  | \"light\"\n  | \"onRemove\"\n  | \"profile\"\n  | \"removeLabel\"\n  | \"shape\"\n  | \"size\"\n  | \"variant\"\n> {\n  /**\n   * The small badge that joins the message, such as \"New\" or \"Error\". It is a\n   * Badge of its own, so text and an icon lay out as in any Badge.\n   */\n  addon: React.ReactNode;\n  /**\n   * `start`, the default, puts the addon before the message and the icon after\n   * it; `end` puts the message first and the addon, with the icon inside it, at\n   * the end of the group.\n   */\n  addonPosition?: BadgeGroupAddonPosition | undefined;\n  /** `light`, the default, or `modern`. */\n  appearance?: BadgeGroupAppearance | undefined;\n  /**\n   * Makes the group a link to this address: it shows the pointer, a hover and\n   * a pressed tint in its own colour and the keyboard focus ring, in every\n   * appearance and colour. For a router's link component or a button, pass\n   * `render` instead. Without either the group is static and has no hover.\n   */\n  href?: string | undefined;\n  /**\n   * The message is the children, one line that ends with an ellipsis where the\n   * group is full.\n   */\n  children?: React.ReactNode;\n  /**\n   * The icon after the message, or inside the addon when it stands at the end:\n   * an arrow by default. Pass `null` for none. Decoration, so give it\n   * `aria-hidden`.\n   */\n  icon?: React.ReactNode;\n  /** `md`, the default, or `lg`. */\n  size?: BadgeGroupSize | undefined;\n  /** The tint, `info` by default. */\n  variant?: BadgeGroupVariant | undefined;\n}\n\n/** Whether a node has anything to show, so its gap and its margin stay out. */\nfunction hasContent(node: React.ReactNode): boolean {\n  return !(\n    node === undefined ||\n    node === null ||\n    node === false ||\n    node === \"\"\n  );\n}\n\n/**\n * One pill that joins a small badge, the addon, and a message: a release note,\n * a warning or an announcement above a heading, with an arrow that says it\n * goes somewhere. It is a Badge, so the tint, the pill geometry and the\n * behaviour of a link or a button (`href`, or `render`: the pointer, the\n * hover and pressed tints and the focus ring) are the Badge's; the addon is a\n * Badge inside it. The group is static unless `href` or `render` makes it a\n * link or a button.\n */\nexport function BadgeGroup({\n  addon,\n  addonPosition = \"start\",\n  appearance = \"light\",\n  children,\n  className,\n  href,\n  icon,\n  render,\n  size = \"md\",\n  variant = \"info\",\n  ...props\n}: BadgeGroupProps): React.ReactElement {\n  const modern = appearance === \"modern\";\n  const end = addonPosition === \"end\";\n  const iconNode =\n    icon === undefined ? <ArrowRightIcon aria-hidden=\"true\" /> : icon;\n  const hasMessage = hasContent(children);\n  const hasIcon = hasContent(iconNode);\n  // The dot of the modern appearance leads the addon, or the group when the\n  // addon stands at the end.\n  const dot = modern ? <BadgeDot variant={variant} /> : null;\n  const addonBadge = (\n    <Badge\n      data-slot=\"badge-group-addon\"\n      shape={modern ? \"default\" : \"pill\"}\n      size={size === \"lg\" ? \"md\" : \"sm\"}\n      variant=\"default\"\n    >\n      {end ? null : dot}\n      {addon}\n      {end ? iconNode : null}\n    </Badge>\n  );\n\n  return (\n    <Badge\n      className={className}\n      data-addon-position={addonPosition}\n      data-appearance={appearance}\n      data-icon={!end && hasIcon ? \"\" : undefined}\n      data-message={hasMessage ? \"\" : undefined}\n      data-slot=\"badge-group\"\n      render={render ?? (href === undefined ? undefined : <a href={href} />)}\n      shape={modern ? \"default\" : \"pill\"}\n      size={size}\n      variant={modern ? \"default\" : variant}\n      {...props}\n    >\n      {/* Three children, not a fragment: the Badge makes the text among its\n          own children the label that ends with an ellipsis, and does not look\n          inside a fragment. */}\n      {end ? dot : addonBadge}\n      {children}\n      {end ? addonBadge : iconNode}\n    </Badge>\n  );\n}\n","type":"registry:ui","target":"~/src/siteplane/components/badge-group/badge-group.tsx"},{"path":"packages/ui/src/components/badge-group/badge-group.css","content":"@layer theme, base, components, siteplane, utilities;\n\n@layer siteplane {\n  /* A badge group is a Badge (the pill block, the tints, the link behaviour in\n   * design-rework.css) around a Badge, the addon, and a message:\n   * a 4 px frame around the addon, 8 px between the addon and the\n   * message and an icon 4 px after the message. Only the sizes the pill block\n   * does not have are named here: the group is as high as its addon and 4 px\n   * above and below it (30 px at md around a 22 px addon, 32 px at lg around a\n   * 24 px one), is as wide as its content and no wider than its space (a flex\n   * column does not stretch it, and the Badge's max-width stays), and sets its\n   * own type. Every rule names the Badge foundation\n   * and the group, so it stands above the pill block whichever stylesheet\n   * comes later. */\n  :root .sp-base-badge.sp-badge-group {\n    --sp-badge-group-lead: var(--sp-rw-space-1);\n    --sp-badge-group-trail: var(--sp-rw-space-2);\n    --sp-badge-group-message-gap: var(--sp-rw-space-2);\n    --sp-badge-group-icon-gap: var(--sp-rw-space-1);\n    --sp-badge-group-dot-gap: var(--sp-rw-space-1-5);\n\n    width: max-content;\n    height: auto;\n    min-width: 0;\n    gap: 0;\n    padding-block: calc(var(--sp-rw-space-1) - var(--sp-rw-border-default));\n    padding-inline-start: calc(\n      var(--sp-badge-group-lead) - var(--sp-rw-border-default)\n    );\n    padding-inline-end: calc(\n      var(--sp-badge-group-trail) - var(--sp-rw-border-default)\n    );\n  }\n\n  :root .sp-base-badge.sp-badge-group[data-size=\"md\"] {\n    --sp-pill-font: var(--sp-rw-font-12);\n    --sp-pill-line: var(--sp-rw-line-18);\n  }\n\n  :root .sp-base-badge.sp-badge-group[data-size=\"lg\"] {\n    --sp-pill-font: var(--sp-rw-font-14);\n    --sp-pill-line: var(--sp-rw-line-20);\n    --sp-badge-group-dot-gap: var(--sp-rw-space-2);\n  }\n\n  /* The addon at the start has the frame at its start and the end of the group\n   * 8 px after the message or the icon; with neither, 4 px, as at its start.\n   * At the end the message starts 12 px in, or 10 px where the modern dot\n   * leads it, and the addon has the 4 px frame at its end. */\n  :root\n    .sp-base-badge.sp-badge-group[data-addon-position=\"start\"]:not(\n      [data-message],\n      [data-icon]\n    ) {\n    --sp-badge-group-trail: var(--sp-rw-space-1);\n  }\n\n  :root .sp-base-badge.sp-badge-group[data-addon-position=\"end\"] {\n    --sp-badge-group-lead: var(--sp-rw-space-3);\n    --sp-badge-group-trail: var(--sp-rw-space-1);\n  }\n\n  :root\n    .sp-base-badge.sp-badge-group[data-addon-position=\"end\"][data-appearance=\"modern\"][data-size=\"md\"] {\n    --sp-badge-group-lead: var(--sp-rw-space-2-5);\n  }\n\n  /* The modern group is a white rounded rectangle, one provider radius, which\n   * its addon's own corner (6 px) is concentric with; a theme that rounds\n   * every badge (--sp-rw-radius-badge) rounds it too. Its text is the\n   * secondary colour and its icon the tertiary one. */\n  :root .sp-base-badge.sp-badge-group[data-appearance=\"modern\"] {\n    --sp-badge-radius: var(--radius);\n    color: var(--sp-rw-fg-secondary);\n  }\n\n  /* The addon takes the group's text colour, which is the tint's on the light\n   * group, and stands 8 px from the message it joins. */\n  :root .sp-base-badge.sp-badge-group > .sp-badge-group-addon {\n    color: inherit;\n  }\n\n  :root\n    .sp-base-badge.sp-badge-group[data-message][data-addon-position=\"start\"]\n    > .sp-badge-group-addon {\n    margin-inline-end: var(--sp-badge-group-message-gap);\n  }\n\n  :root\n    .sp-base-badge.sp-badge-group[data-message][data-addon-position=\"end\"]\n    > .sp-badge-group-addon {\n    margin-inline-start: var(--sp-badge-group-message-gap);\n  }\n\n  /* The icon after the message is 16 px and 4 px from it. At the end it is the\n   * addon's, a 12 px icon like any Badge icon. */\n  :root .sp-base-badge.sp-badge-group > svg:not([class*=\"size-\"]) {\n    width: var(--sp-rw-space-4);\n    height: var(--sp-rw-space-4);\n    margin-inline-start: var(--sp-badge-group-icon-gap);\n  }\n\n  :root .sp-base-badge.sp-badge-group[data-appearance=\"modern\"] > svg {\n    color: var(--sp-rw-fg-tertiary);\n  }\n\n  /* The dot that leads a group with its addon at the end: 8 px, 6 px or 8 px\n   * before the message, with no margin of its own at its start. */\n  :root .sp-base-badge.sp-badge-group > .sp-badge-dot {\n    margin: 0;\n    margin-inline-end: var(--sp-badge-group-dot-gap);\n  }\n}\n","type":"registry:ui","target":"~/src/siteplane/components/badge-group/badge-group.css"},{"path":"packages/ui/src/components/badge-group/index.ts","content":"export * from \"./badge-group\";\n","type":"registry:ui","target":"~/src/siteplane/components/badge-group/index.ts"}],"type":"registry:ui","docs":"https://ui.siteplane.io/docs-markdown/components/badge-group.md","categories":["Data display"],"meta":{"avoidWhen":["Avoid for a label on its own; use Badge.","Avoid for a message that needs a description or an action; use Alert."],"description":"Join a small badge and a message in one pill, such as a release note or a status line above a heading.","knownLimitations":["The message stays on one line and ends with an ellipsis where the group meets the edge of its space.","The arrow and the modern dot are decoration, hidden from assistive technology; the words carry the meaning."],"providerNotes":[],"releaseStatus":"preview","searchTerms":["badge group","announcement badge","release note badge","new feature badge","pill","notice"],"useWhen":["Use for one short piece of news in a prominent place, such as a release note above a page heading or a status line at the top of a panel.","Use the modern appearance on a busy or tinted surface, where a white group with a colored dot reads better than a tint."]}}