{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "overflow-menu",
  "type": "registry:ui",
  "title": "<ui-overflow-menu>",
  "description": "Carbon `OverflowMenu` (v12): a ghost icon button (\"⋮\", named by `label` through an icon tooltip) that opens a `<ui-menu>` of the slotted items. Sizes sm 32 / md 40 / lg 48px. Listen for `ui-select` on this element; `event.target` is the activated `<ui-menu-item>`. 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/menu",
    "@kanok-ui/shared-align",
    "@kanok-ui/shared-element",
    "@kanok-ui/shared-events",
    "@kanok-ui/shared-field",
    "@kanok-ui/shared-localize",
    "@kanok-ui/tooltip",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/overflow-menu/overflow-menu.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/overflow-menu/overflow-menu.ts",
      "content": "import { LitElement, html, css } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { uid } from '../shared/field.ts';\nimport type { TooltipPlacement } from '../tooltip/tooltip.ts';\nimport { openMenuFromKey, type MenuPlacement, type MenuSize, type UiMenu, type MenuSelectDetail } from '../menu/menu.ts';\nimport '../tooltip/tooltip.ts';\nimport '../menu/menu.ts';\nimport { LocalizeController } from '../shared/localize.ts';\nimport { isOwnEvent, type OpenDetail } from '../shared/events.ts';\nimport { WithAlign } from '../shared/align.ts';\nimport { UiElement } from '../shared/element.ts';\n\nexport type OverflowMenuSize = 'sm' | 'md' | 'lg';\n\nconst dots = html`<svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><circle cx=\"8\" cy=\"4\" r=\"1.5\" /><circle cx=\"8\" cy=\"8\" r=\"1.5\" /><circle cx=\"8\" cy=\"12\" r=\"1.5\" /></svg>`;\n\n/**\n * Carbon `OverflowMenu` (v12): a ghost icon button (\"⋮\", named by `label` through an icon\n * tooltip) that opens a `<ui-menu>` of the slotted items. Sizes sm 32 / md 40 / lg 48px.\n * Listen for `ui-select` on this element; `event.target` is the activated `<ui-menu-item>`.\n *\n * @slot - `<ui-menu-item>`, `<ui-menu-divider>`, `<ui-menu-group>`\n * @slot icon - Replaces the \"⋮\" icon\n * @fires ui-select - bubbles from the activated item: detail { value, label, checked }\n * @fires ui-toggle - detail: { open }\n * @csspart trigger - The icon button\n * @csspart menu - The `<ui-menu>`\n * @attr align - Carbon's name for `placement` (same values)\n * @cssprop --ui-button-radius - Corner radius of the trigger (the button setting)\n * @cssprop --ui-overflow-open-background / --ui-overflow-open-shadow - The trigger while open (default: it joins the menu, Carbon's look)\n * @cssprop --ui-focus-offset - `outline-offset` of its focus ring (default -2px: inside; Kanok: 2px outside)\n */\n@customElement('ui-overflow-menu')\nexport class UiOverflowMenu extends WithAlign(UiElement) {\n    /** `el.focus()` lands on the control inside. */\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            display: inline-block;\n        }\n\n        .trigger {\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            inline-size: var(--_s, 40px);\n            block-size: var(--_s, 40px);\n            padding: 0;\n            border: none;\n            border-radius: var(--ui-button-radius, 0); /* an icon button: the button setting */\n            background-color: transparent;\n            color: var(--ui-icon-primary);\n            cursor: pointer;\n            outline: none;\n            /* Carbon .cds--overflow-menu: 110ms, entrance productive */\n            transition:\n                outline var(--ui-duration-moderate) var(--ui-easing-entrance),\n                background-color var(--ui-duration-moderate) var(--ui-easing-entrance);\n        }\n\n        :host([size='sm']) .trigger {\n            --_s: 32px;\n        }\n\n        :host([size='lg']) .trigger {\n            --_s: 48px;\n        }\n\n        /* Carbon: background-hover */\n        .trigger:hover {\n            background-color: var(--ui-canvas-hover);\n        }\n\n        .trigger:focus-visible {\n            outline: var(--ui-focus-width, 2px) solid var(--ui-focus);\n            outline-offset: var(--ui-focus-offset, -2px);\n        }\n\n        /* Carbon: open, the trigger joins the menu (its fill and shadow); a design can leave it a pressed button */\n        .trigger[aria-expanded='true'] {\n            background-color: var(--ui-overflow-open-background, var(--ui-surface-1));\n            box-shadow: var(--ui-overflow-open-shadow, 0 2px 6px rgb(0 0 0 / 0.3));\n            transition: none;\n        }\n\n        .trigger:disabled {\n            background-color: transparent;\n            color: var(--ui-icon-disabled);\n            cursor: not-allowed;\n        }\n\n        svg,\n        ::slotted([slot='icon']) {\n            width: 16px;\n            height: 16px;\n            fill: currentColor;\n        }\n\n        @media (forced-colors: active) {\n            .trigger {\n                color: CanvasText;\n            }\n\n            .trigger[aria-expanded='true'] {\n                outline: 1px solid CanvasText;\n            }\n\n            .trigger:disabled {\n                color: GrayText;\n            }\n        }\n\n    `;\n\n    /** Accessible name of the trigger and the menu. */\n    @property() label = '';\n\n    private readonly localize = new LocalizeController(this);\n\n    @property({ reflect: true }) size: OverflowMenuSize = 'md';\n\n    @property() placement: MenuPlacement = 'bottom-start';\n\n    @property({ attribute: 'tooltip-placement' }) tooltipPlacement: TooltipPlacement = 'bottom';\n\n    @property({ type: Boolean, reflect: true }) disabled = false;\n\n    @property({ type: Boolean, reflect: true }) open = false;\n\n    @query('.trigger') private readonly trigger!: HTMLButtonElement;\n\n    @query('ui-menu') private readonly menu!: UiMenu;\n\n    private readonly menuId = uid('ui-overflow-menu');\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (changed.has('open') && this.menu.open !== this.open) {\n            this.menu.anchor = this.trigger;\n            this.menu.open = this.open;\n        }\n    }\n\n    private onTriggerKeydown(event: KeyboardEvent) {\n        openMenuFromKey(event, this.menu, this.trigger);\n    }\n\n    private toggle() {\n        if (this.open) this.menu.hide();\n        else this.menu.show(this.trigger);\n    }\n\n    override render() {\n        const menuSize: MenuSize = this.size;\n        return html`\n            <ui-tooltip as-label text=${this.label || this.localize.t.common.options} placement=${this.tooltipPlacement}>\n                <button\n                    class=\"trigger\"\n                    part=\"trigger\"\n                    type=\"button\"\n                    tabindex=\"0\"\n                    aria-haspopup=\"true\"\n                    aria-expanded=${this.open ? 'true' : 'false'}\n                    aria-controls=${this.menuId}\n                    ?disabled=${this.disabled}\n                    @click=${this.toggle}\n                    @keydown=${this.onTriggerKeydown}\n                >\n                    <slot name=\"icon\">${dots}</slot>\n                </button>\n            </ui-tooltip>\n            <ui-menu\n                id=${this.menuId}\n                part=\"menu\"\n                label=${this.label || this.localize.t.common.options}\n                size=${menuSize}\n                placement=${this.placement}\n                @ui-toggle=${(e: CustomEvent<{ open: boolean }>) => { if (isOwnEvent(e)) this.open = e.detail.open; }}\n            >\n                <slot></slot>\n            </ui-menu>\n        `;\n    }\n}\n\nexport interface UiOverflowMenuEventMap extends HTMLElementEventMap {\n    'ui-select': CustomEvent<MenuSelectDetail>;\n    'ui-toggle': CustomEvent<OpenDetail>;\n}\n\n/** Typed listeners for UiOverflowMenu's events (declaration merging with the class). */\nexport interface UiOverflowMenu {\n    addEventListener<K extends keyof UiOverflowMenuEventMap>(type: K, listener: (this: UiOverflowMenu, event: UiOverflowMenuEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiOverflowMenuEventMap>(type: K, listener: (this: UiOverflowMenu, event: UiOverflowMenuEventMap[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-overflow-menu': UiOverflowMenu;\n    }\n}\n"
    }
  ]
}
