{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "combo-button",
  "type": "registry:ui",
  "title": "<ui-combo-button>",
  "description": "Carbon `ComboButton`: a primary action button next to a chevron that opens a `<ui-menu>` of secondary actions. The primary button fires `ui-click` (Carbon `onClick`; a plain `click` on the element also bubbles from the chevron and the menu items); menu items fire `ui-select`. Sizes sm / md / lg; `placement` bottom (menu as wide as the whole control) or top / -start / -end. 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": [
    "lit@^3.3.0"
  ],
  "registryDependencies": [
    "@kanok-ui/button",
    "@kanok-ui/icon-button",
    "@kanok-ui/menu",
    "@kanok-ui/shared-align",
    "@kanok-ui/shared-element",
    "@kanok-ui/shared-events",
    "@kanok-ui/shared-localize",
    "@kanok-ui/tooltip",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/combo-button/combo-button.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/combo-button/combo-button.ts",
      "content": "import { LitElement, html, css } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport type { ButtonSize } from '../button/button.ts';\nimport { openMenuFromKey, type MenuPlacement, type UiMenu, type MenuSelectDetail } from '../menu/menu.ts';\nimport type { TooltipPlacement } from '../tooltip/tooltip.ts';\nimport { LocalizeController } from '../shared/localize.ts';\nimport '../button/button.ts';\nimport '../icon-button/icon-button.ts';\nimport '../menu/menu.ts';\nimport { isOwnEvent, type OpenDetail } from '../shared/events.ts';\nimport { WithAlign } from '../shared/align.ts';\nimport { UiElement } from '../shared/element.ts';\n\n/**\n * Carbon `ComboButton`: a primary action button next to a chevron that opens a `<ui-menu>` of\n * secondary actions. The primary button fires `ui-click` (Carbon `onClick`; a plain `click` on the element\n * also bubbles from the chevron and the menu items); menu items fire `ui-select`. Sizes\n * sm / md / lg; `placement` bottom (menu as wide as the whole control) or top / -start / -end.\n *\n * @slot - `<ui-menu-item>` elements (secondary actions)\n * @fires ui-click - the primary button was activated (not the chevron or a menu item)\n * @fires ui-select - bubbles from the activated item\n * @fires ui-toggle - detail: { open }\n * @csspart primary - The primary `<ui-button>`\n * @csspart trigger - The chevron `<ui-icon-button>`\n * @csspart menu - The `<ui-menu>`\n * @attr align - Carbon's name for `placement` (same values)\n */\n@customElement('ui-combo-button')\nexport class UiComboButton extends WithAlign(UiElement) {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            display: inline-flex;\n            column-gap: 1px;\n            font-family: var(--ui-font-family);\n        }\n\n        .primary {\n            --_ui-button-radius-end: 0px; /* one control: the primary button and the chevron join square (a rounded design rounds only the outer ends) */\n\n            min-inline-size: calc(160px - 1px - var(--_t, 48px));\n        }\n\n        ui-icon-button {\n            --_ui-button-radius-start: 0px;\n        }\n\n        :host([size='md']) .primary {\n            --_t: 40px;\n        }\n\n        :host([size='sm']) .primary {\n            --_t: 32px;\n        }\n\n        .primary ui-button {\n            inline-size: 100%;\n            min-inline-size: 111px;\n            max-inline-size: 239px;\n        }\n\n        .primary ui-button::part(base) {\n            inline-size: 100%;\n            overflow: hidden;\n            text-overflow: ellipsis;\n            white-space: nowrap;\n        }\n\n        .chevron {\n            transition: transform var(--ui-duration-moderate) var(--ui-easing);\n        }\n\n        :host([open]) .chevron {\n            transform: rotate(180deg);\n        }\n    `;\n\n    /** Primary action text. */\n    @property() label = '';\n\n    /** sm 32 / md 40 / lg 48px (Carbon has no xl / 2xl here). */\n    @property({ reflect: true }) size: Exclude<ButtonSize, 'xl' | '2xl'> = 'lg';\n\n    @property() placement: MenuPlacement = 'bottom';\n\n    @property({ attribute: 'tooltip-placement' }) tooltipPlacement: TooltipPlacement = 'bottom';\n\n    /** Name of the chevron button; defaults to the translation (\"Additional actions\"). */\n    @property({ attribute: 'trigger-label' }) triggerLabel = '';\n\n    @property({ type: Boolean, reflect: true }) disabled = false;\n\n    @property({ type: Boolean, reflect: true }) open = false;\n\n    @query('ui-menu') private readonly menu!: UiMenu;\n\n    private readonly localize = new LocalizeController(this);\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (changed.has('open') && this.menu.open !== this.open) {\n            this.menu.anchor = this;\n            this.menu.open = this.open;\n        }\n    }\n\n    private onTriggerKeydown(event: KeyboardEvent) {\n        openMenuFromKey(event, this.menu, this);\n    }\n\n    private readonly onPrimaryClick = () => {\n        if (this.disabled) return;\n        this.dispatchEvent(new CustomEvent('ui-click', { bubbles: true, composed: true }));\n    };\n\n    private toggle() {\n        if (this.open) this.menu.hide();\n        else this.menu.show(this);\n    }\n\n    override render() {\n        const triggerLabel = this.triggerLabel || this.localize.t.common.additionalActions;\n        const fullWidth = this.placement === 'bottom' || this.placement === 'top';\n        return html`\n            <div class=\"primary\"><ui-button part=\"primary\" kind=\"primary\" size=${this.size} ?disabled=${this.disabled} @click=${this.onPrimaryClick}>${this.label}</ui-button></div>\n            <ui-icon-button\n                part=\"trigger\"\n                kind=\"primary\"\n                size=${this.size}\n                label=${triggerLabel}\n                tooltip-placement=${this.tooltipPlacement}\n                haspopup=\"menu\"\n                ?expanded=${this.open}\n                ?disabled=${this.disabled}\n                @click=${this.toggle}\n                @keydown=${this.onTriggerKeydown}\n            >\n                <svg class=\"chevron\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M8 11 3 6l.7-.7L8 9.6l4.3-4.3.7.7z\" /></svg>\n            </ui-icon-button>\n            <ui-menu part=\"menu\" label=${triggerLabel} size=${this.size} placement=${this.placement} ?match-width=${fullWidth} @ui-toggle=${(e: CustomEvent<{ open: boolean }>) => { if (isOwnEvent(e)) this.open = e.detail.open; }}>\n                <slot></slot>\n            </ui-menu>\n        `;\n    }\n}\n\nexport interface UiComboButtonEventMap extends HTMLElementEventMap {\n    'ui-click': CustomEvent<undefined>;\n    'ui-select': CustomEvent<MenuSelectDetail>;\n    'ui-toggle': CustomEvent<OpenDetail>;\n}\n\n/** Typed listeners for UiComboButton's events (declaration merging with the class). */\nexport interface UiComboButton {\n    addEventListener<K extends keyof UiComboButtonEventMap>(type: K, listener: (this: UiComboButton, event: UiComboButtonEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiComboButtonEventMap>(type: K, listener: (this: UiComboButton, event: UiComboButtonEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;\n    removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-combo-button': UiComboButton;\n    }\n}\n"
    }
  ]
}
